From: Sascha Schumann Date: Wed, 24 May 2000 14:46:13 +0000 (+0000) Subject: The behaviour for result == NULL || entry == NULL is undefined. X-Git-Tag: PRE_EIGHT_BYTE_ALLOC_PATCH~265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a86e37d69993ba8aa6c670d21cc0572f19e6da7;p=php The behaviour for result == NULL || entry == NULL is undefined. --- diff --git a/main/reentrancy.c b/main/reentrancy.c index 4677d52ea2..866cf4273e 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -127,11 +127,10 @@ PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry, if (!ptr && errno != 0) ret = errno; - if (entry && ptr) + if (ptr) memcpy(entry, ptr, sizeof(*ptr)); - if (result) - *result = ptr; + *result = ptr; local_unlock(READDIR_R); diff --git a/win32/readdir.c b/win32/readdir.c index a9cfa3a513..ed799a6747 100644 --- a/win32/readdir.c +++ b/win32/readdir.c @@ -74,16 +74,14 @@ struct dirent *readdir(DIR *dp) int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result) { if (!dp || dp->finished) { - if (result) - *result = NULL; + *result = NULL; return 0; } if (dp->offset != 0) { if (_findnext(dp->handle, &(dp->fileinfo)) < 0) { dp->finished = 1; - if (result) - *result = NULL; + *result = NULL; return 0; } } @@ -94,11 +92,9 @@ int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result) dp->dent.d_reclen = strlen(dp->dent.d_name); dp->dent.d_off = dp->offset; - if (entry) - memcpy(entry, &dp->dent, sizeof(*entry)); + memcpy(entry, &dp->dent, sizeof(*entry)); - if (result) - *result = &dp->dent; + *result = &dp->dent; return 0; }