summaryrefslogtreecommitdiff
path: root/win32/ioutil.h
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-07-29 13:33:58 +0200
committerAnatol Belski <ab@php.net>2016-07-29 13:33:58 +0200
commit6dbfd4287bfb4de8bc7446f3c09ccce4e75368b6 (patch)
tree5bbf6ff9f3afbc62e6de878d06106117017ed0aa /win32/ioutil.h
parent0596a2561bd29d7438cecb39b574fa523707737e (diff)
downloadphp-git-6dbfd4287bfb4de8bc7446f3c09ccce4e75368b6.tar.gz
move error check to right place
this only makes sense when length was passed
Diffstat (limited to 'win32/ioutil.h')
-rw-r--r--win32/ioutil.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/win32/ioutil.h b/win32/ioutil.h
index d2e8239075..2a02d52c51 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);
}