mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
- fix possible NULL deref
This commit is contained in:
parent
eda798fd7a
commit
26bb38e68b
1 changed files with 6 additions and 0 deletions
|
@ -1874,6 +1874,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
|
||||||
/* realpath("") returns CWD */
|
/* realpath("") returns CWD */
|
||||||
if (!*path) {
|
if (!*path) {
|
||||||
new_state.cwd = (char*)malloc(1);
|
new_state.cwd = (char*)malloc(1);
|
||||||
|
if (new_state.cwd == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
new_state.cwd[0] = '\0';
|
new_state.cwd[0] = '\0';
|
||||||
new_state.cwd_length = 0;
|
new_state.cwd_length = 0;
|
||||||
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
|
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
|
||||||
|
@ -1885,6 +1888,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
|
||||||
new_state.cwd_length = strlen(cwd);
|
new_state.cwd_length = strlen(cwd);
|
||||||
} else {
|
} else {
|
||||||
new_state.cwd = (char*)malloc(1);
|
new_state.cwd = (char*)malloc(1);
|
||||||
|
if (new_state.cwd == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
new_state.cwd[0] = '\0';
|
new_state.cwd[0] = '\0';
|
||||||
new_state.cwd_length = 0;
|
new_state.cwd_length = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue