diff options
-rw-r--r-- | TSRM/tsrm_virtual_cwd.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index b0fd1ae8ab..2335d5e890 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -1874,6 +1874,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ /* realpath("") returns CWD */ if (!*path) { new_state.cwd = (char*)malloc(1); + if (new_state.cwd == NULL) { + return NULL; + } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; 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); } else { new_state.cwd = (char*)malloc(1); + if (new_state.cwd == NULL) { + return NULL; + } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; } |