summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2011-01-10 08:07:38 +0000
committerPierre Joye <pajoye@php.net>2011-01-10 08:07:38 +0000
commit639d3fbcfb1f859cb29bbd251a6ff8113ccb9a97 (patch)
treeb7a96e740d31c359511ac71e392720aaab7a6122
parent10a1f90ab046bbca89c3cf4b8e843821b3b0260f (diff)
downloadphp-git-639d3fbcfb1f859cb29bbd251a6ff8113ccb9a97.tar.gz
- possible NULL deref
-rw-r--r--win32/readdir.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/win32/readdir.c b/win32/readdir.c
index 52ebe2fd09..9525fc0d6b 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] == '/' ||