Wargus / war1gus

Importer and scripts for Warcraft: Orcs and Humans
GNU General Public License v2.0
101 stars 14 forks source link

Potential Memory Leak #426

Open weiweiwei9811 opened 1 year ago

weiweiwei9811 commented 1 year ago

in war1tool.cpp:3669, the return of realpath() is not freed, this could cause memory leak.

base on the document, If resolved_path is specified as NULL, then realpath() uses malloc to allocate a buffer of up to PATH_MAX bytes to hold the resolved pathname, and returns a pointer to this buffer. The caller should deallocate this buffer using free.

in window platform, the realpath is defined as _fullpath, and from document,it is same as realpath in linux.

timfel commented 1 year ago

I am sure there are many memory leaks in war1tool :) It's a short running script, so I never really bothered to fix them (all platforms we support have OS-level reclaiming of virtual address space). PRs are welcome, but from my side I doubt it will get fixed