1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 07:58:20 +02:00

move error check to right place

this only makes sense when length was passed
This commit is contained in:
Anatol Belski
2016-07-29 13:33:58 +02:00
parent 0596a2561b
commit 6dbfd4287b
+5 -4
View File
@@ -437,16 +437,17 @@ __forceinline static char *php_win32_ioutil_getcwd(char *buf, int len)
free(tmp_bufa);
SET_ERRNO_FROM_WIN32_CODE(ERROR_BAD_LENGTH);
return NULL;
} else if (tmp_bufa_len + 1 > len) {
free(tmp_bufa);
SET_ERRNO_FROM_WIN32_CODE(ERROR_INSUFFICIENT_BUFFER);
return NULL;
}
if (!buf) {
/* If buf was NULL, the result has to be freed outside here. */
buf = tmp_bufa;
} else {
if (tmp_bufa_len + 1 > len) {
free(tmp_bufa);
SET_ERRNO_FROM_WIN32_CODE(ERROR_INSUFFICIENT_BUFFER);
return NULL;
}
memmove(buf, tmp_bufa, tmp_bufa_len + 1);
free(tmp_bufa);
}