com php-src: move error check to right place: win32/ioutil.h
| From: | Anatol Belski | Date: | Fri, 29 Jul 2016 11:33:58 +0000 |
| Subject: | com php-src: move error check to right place: win32/ioutil.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93472@lists.php.net to get a copy of this message | ||
Commit: 6dbfd4287bfb4de8bc7446f3c09ccce4e75368b6
Author: Anatol Belski <ab@php.net> Fri, 29 Jul 2016 13:33:58 +0200
Parents: 0596a2561bd29d7438cecb39b574fa523707737e
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6dbfd4287bfb4de8bc7446f3c09ccce4e75368b6
Log:
move error check to right place
this only makes sense when length was passed
Changed paths:
M win32/ioutil.h
Diff:
diff --git a/win32/ioutil.h b/win32/ioutil.h
index d2e8239..2a02d52 100644
--- a/win32/ioutil.h
+++ b/win32/ioutil.h
@@ -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);
}