From 8640b61c68fd61dfe999f178c61ff722f000a441 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Mon, 10 Jan 2011 00:30:07 +0000 Subject: [PATCH] - fix possible NULL deref --- TSRM/tsrm_virtual_cwd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 8cf7226384..8d8eb36db5 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -1887,6 +1887,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)) { @@ -1898,6 +1901,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; } -- 2.50.1