This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 2560e1686595870e0bdcae13ae6f584bfe11f456 Author: Robert Lazarski <[email protected]> AuthorDate: Sat Jan 10 10:02:50 2026 -1000 Fix memory leaks in Windows axis2_scandir error paths (AXIS2C-1376) In axis2_scandir() on Windows, two error paths were leaking memory: 1. When realloc() fails: The existing vector entries, vector itself, and the open directory handle (dirp) were not being freed. 2. When malloc() fails for a new dirent: The directory handle (dirp) was not being closed (vector cleanup was already present). Added proper cleanup in both error paths to free all allocated resources before returning -1. Note: This is Windows-only code (not compiled on Linux/Unix). Co-Authored-By: Claude Opus 4.5 <[email protected]> --- util/src/platforms/windows/dir_windows.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/src/platforms/windows/dir_windows.c b/util/src/platforms/windows/dir_windows.c index fe0e19d94..bc73c677e 100644 --- a/util/src/platforms/windows/dir_windows.c +++ b/util/src/platforms/windows/dir_windows.c @@ -246,6 +246,12 @@ axis2_scandir( newv = (struct dirent **)realloc(vector, vector_size * sizeof(struct dirent *)); if(!newv) { + while(nfiles-- > 0) + { + free(vector[nfiles]); + } + free(vector); + axis2_closedir(dirp); return -1; } vector = newv; @@ -264,6 +270,7 @@ axis2_scandir( free(vector[nfiles]); } free(vector); + axis2_closedir(dirp); return -1; }
