From: Pierre Joye Date: Mon, 10 Jan 2011 00:30:07 +0000 (+0000) Subject: - fix possible NULL deref X-Git-Tag: php-5.4.0alpha1~191^2~397 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26bb38e68ba1352440793df17eeb3bbdf1fbce7c;p=php - fix possible NULL deref --- 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; }