HereBeDragons-1.0

8 - Parameter sanitizing needed in GetZoneCoordinatesFromWorld

In function GetZoneCoordinatesFromWorld, parameters x and y are not sanitized. If they are nil, an exception will be raised when the function tries to perform arithmetic on them. This is currently causing a problem with at least one addon using HBD, GatherMate.

The following patch against git master (at the time of writing) fixes this problem:

diff --git a/HereBeDragons-1.0.lua b/HereBeDragons-1.0.lua
index cb2f097..185faa3 100644
--- a/HereBeDragons-1.0.lua
+++ b/HereBeDragons-1.0.lua
@@ -614,7 +614,7 @@ end
 -- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned
 function HereBeDragons:GetZoneCoordinatesFromWorld(x, y, zone, level, allowOutOfBounds)
     local data = getMapDataTable(zone, level)
-    if not data or data[0] == 0 or data[1] == 0 then return nil, nil end
+    if not data or data[0] == 0 or data[1] == 0 or x == nil or y == nil then return nil, nil end

     local width, height, left, top = data[1], data[2], data[3], data[4]
     x, y = (left - x) / width, (top - y) / height
User When Change
InfernusKnight Oct 26, 2016 at 08:10 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

Facts

Reported
Oct 26, 2016
Status
New - Issue has not had initial review yet.
Type
Defect - A shortcoming, fault, or imperfection
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees