summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2011-01-10 08:07:38 (GMT)
committerPierre Joye <pajoye@php.net>2011-01-10 08:07:38 (GMT)
commitf25ab1bf9c46e0c65399de3fbcae47f3af1ac0b4 (patch)
tree565d66d7ec0deac8e88acb6d5a1d0400505651bd /win32
parentf45b9c4a0be23c1f9cb9235b43d80af7827ed20a (diff)
downloadphp-f25ab1bf9c46e0c65399de3fbcae47f3af1ac0b4.tar.gz
- possible NULL deref
Diffstat (limited to 'win32')
-rw-r--r--win32/readdir.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/win32/readdir.c b/win32/readdir.c
index 52ebe2f..9525fc0 100644
--- a/win32/readdir.c
+++ b/win32/readdir.c
@@ -33,6 +33,9 @@ DIR *opendir(const char *dir)
}
filespec = (char *)malloc(strlen(resolved_path_buff) + 2 + 1);
+ if (filespec == NULL) {
+ return NULL;
+ }
strcpy(filespec, resolved_path_buff);
index = strlen(filespec) - 1;
if (index >= 0 && (filespec[index] == '/' ||
@@ -41,6 +44,9 @@ DIR *opendir(const char *dir)
strcat(filespec, "\\*");
dp = (DIR *) malloc(sizeof(DIR));
+ if (dp == NULL) {
+ return NULL;
+ }
dp->offset = 0;
dp->finished = 0;
@@ -140,6 +146,10 @@ int rewinddir(DIR *dp)
dp->finished = 0;
filespec = (char *)malloc(strlen(dp->dir) + 2 + 1);
+ if (filespec == NULL) {
+ return -1;
+ }
+
strcpy(filespec, dp->dir);
index = strlen(filespec) - 1;
if (index >= 0 && (filespec[index] == '/' ||