diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-25 04:09:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-25 04:09:19 +0300 |
commit | 269ee1e98ef1645957276ba4160c96db307f1771 (patch) | |
tree | f810e934c7af5eb2df742933bf1566a2a8cede28 | |
parent | 9373adc5956b57f2b8bc16ba0c66ffcc031b9c2f (diff) | |
download | mv-269ee1e98ef1645957276ba4160c96db307f1771.tar.gz mv-269ee1e98ef1645957276ba4160c96db307f1771.tar.bz2 mv-269ee1e98ef1645957276ba4160c96db307f1771.tar.xz mv-269ee1e98ef1645957276ba4160c96db307f1771.zip |
Add missing checks.
-rw-r--r-- | src/map.cpp | 6 | ||||
-rw-r--r-- | src/utils/mkdir.cpp | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/map.cpp b/src/map.cpp index 23089db4e..f79539567 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1001,6 +1001,9 @@ Path Map::findPath(int startX, int startY, int destX, int destY, // Path to be built up (empty by default) Path path; + if (startX >= mWidth || startY >= mHeight) + return path; + // Declare open list, a list with open tiles sorted on F cost std::priority_queue<Location> openList; @@ -1601,6 +1604,9 @@ void SpecialLayer::addRoad(Path road) void SpecialLayer::clean() { + if (!mTiles) + return; + for (int f = 0; f < mWidth * mHeight; f ++) { MapItem *item = mTiles[f]; diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp index f0cc65f53..4ab9f7d61 100644 --- a/src/utils/mkdir.cpp +++ b/src/utils/mkdir.cpp @@ -80,7 +80,7 @@ int mkdir_r(const char *pathname) } else { - delete tmp; + delete []tmp; return -1; } } @@ -97,7 +97,7 @@ int mkdir_r(const char *pathname) if (!(strlen(tmp) == 2 && !strcmp(tmp + 1, ":"))) #endif - delete tmp; + delete []tmp; return -1; } @@ -107,7 +107,7 @@ int mkdir_r(const char *pathname) *p = '/'; } } - delete tmp; + delete []tmp; return 0; } |