]> granicus.if.org Git - php/commitdiff
MFB: Fixed php_readdir_r() usage in scandir emulation
authorIlia Alshanetsky <iliaa@php.net>
Sun, 3 Dec 2006 15:52:37 +0000 (15:52 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 3 Dec 2006 15:52:37 +0000 (15:52 +0000)
main/php_scandir.c

index 6b32e8108790ee0ce37aad939c9d1ad82bc8d360..7513dce1e9dc2dbf2b5a0e5ffd9a723997d85224 100644 (file)
@@ -61,11 +61,10 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector)
 {
        DIR *dirp = NULL;
        struct dirent **vector = NULL;
-       struct dirent *dp = NULL;
        int vector_size = 0;
        int nfiles = 0;
        char entry[sizeof(struct dirent)+MAXPATHLEN];
-       struct dirent *result = (struct dirent *)&entry;
+       struct dirent *dp = (struct dirent *)&entry;
 
        if (namelist == NULL) {
                return -1;
@@ -75,7 +74,7 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector)
                return -1;
        }
 
-       while ((dp = php_readdir_r(dirp, (struct dirent *)entry, &result)) == 0 && result) {
+       while (!php_readdir_r(dirp, (struct dirent *)entry, &dp) && dp) {
                int dsize = 0;
                struct dirent *newdp = NULL;