]> granicus.if.org Git - php/commitdiff
- fix possible NULL deref
authorPierre Joye <pajoye@php.net>
Mon, 10 Jan 2011 00:30:07 +0000 (00:30 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 10 Jan 2011 00:30:07 +0000 (00:30 +0000)
TSRM/tsrm_virtual_cwd.c

index 8cf722638441b48c9164901b4febbfc7a640b2ba..8d8eb36db5d8a178cc776e79f9c324dfc5021294 100644 (file)
@@ -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;
        }