]> 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 b0fd1ae8ab724b694d3dcc4f51dbdc4d77a6b7a5..2335d5e89011f9a196879730f159a8701d8fe97c 100644 (file)
@@ -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;
        }