summaryrefslogtreecommitdiff
path: root/win32/readdir.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-06-09 14:18:14 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-06-09 14:18:14 +0000
commitccc580f408c5f3fc09e95318a7e2a4e816d7e986 (patch)
tree57c9e5fedc2546dca7356668b23dc8fd68d5aae6 /win32/readdir.c
parent1f73efcaab177e870811e4d0a66126b9d6e006d6 (diff)
downloadphp-git-ccc580f408c5f3fc09e95318a7e2a4e816d7e986.tar.gz
Fixed memory leak on error in win32's opendir() emulation. (Patch by Wez)
Diffstat (limited to 'win32/readdir.c')
-rw-r--r--win32/readdir.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/win32/readdir.c b/win32/readdir.c
index e33d19bde5..6aaafced44 100644
--- a/win32/readdir.c
+++ b/win32/readdir.c
@@ -37,14 +37,17 @@ DIR *opendir(const char *dir)
dp = (DIR *) malloc(sizeof(DIR));
dp->offset = 0;
dp->finished = 0;
- dp->dir = strdup(dir);
if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
- if (errno == ENOENT)
+ if (errno == ENOENT) {
dp->finished = 1;
- else
+ } else {
+ free(dp);
+ free(filespec);
return NULL;
+ }
}
+ dp->dir = strdup(dir);
dp->handle = handle;
free(filespec);