diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index dd01d1c8e8..decae4ba5d 100755 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -226,7 +226,7 @@ static HDATA* h_data_any_type(const Handle h) // used by most functions accessing handle data. static HDATA* h_data(const Handle h, const H_Type type) { - if(!h) + if(h <= 0) return 0; HDATA* hd = h_data_any_type(h); @@ -349,6 +349,10 @@ static int free_idx(i32 idx) int h_free(Handle& h, H_Type type) { HDATA* hd = h_data(h, type); + h = 0; + // wipe out the handle, to prevent reuse. + // TODO: should we do this after checking if valid? + // (would help debugging, but handle wouldn't always be reset) if(!hd) return ERR_INVALID_HANDLE; diff --git a/source/lib/res/tex.cpp b/source/lib/res/tex.cpp index 9b346e68df..4ccb8ba5c5 100755 --- a/source/lib/res/tex.cpp +++ b/source/lib/res/tex.cpp @@ -504,7 +504,8 @@ static inline bool bmp_fmt(u8* p, size_t size) { UNUSED(size) - // bfType == BM? (check single bytes => endian safe) + // check header signature (BITMAPFILEHEADER.bfType == "BM"?). + // we compare single bytes to be endian-safe. return p[0] == 'B' && p[1] == 'M'; }