]> granicus.if.org Git - php/commitdiff
- Fix #48746, improve fix to support all possible cases (see latest comment in the...
authorPierre Joye <pajoye@php.net>
Mon, 14 Sep 2009 18:46:56 +0000 (18:46 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 14 Sep 2009 18:46:56 +0000 (18:46 +0000)
TSRM/tsrm_virtual_cwd.c

index 07708a7cfb4eb1cf9e20b74c949406e7eb1b67e1..6b84a3bdaf15556c828f35d7e44f09946d05e411 100644 (file)
@@ -905,6 +905,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
        time_t t;
        int ret;
        int add_slash;
+       void *tmp;
        TSRMLS_FETCH();
 
        if (path_length == 0 || path_length >= MAXPATHLEN-1) {
@@ -1049,7 +1050,16 @@ verify:
 
                CWD_STATE_COPY(&old_state, state);
                state->cwd_length = path_length;
-               state->cwd = (char *) realloc(state->cwd, state->cwd_length+1);
+
+               tmp = realloc(state->cwd, state->cwd_length+1);
+               if (tmp == NULL) {
+#if VIRTUAL_CWD_DEBUG
+                       fprintf (stderr, "Out of memory\n");
+#endif
+                       return 1;
+               }
+               state->cwd = (char *) tmp;
+
                memcpy(state->cwd, resolved_path, state->cwd_length+1);
                if (verify_path(state)) {
                        CWD_STATE_FREE(state);
@@ -1061,7 +1071,15 @@ verify:
                }
        } else {
                state->cwd_length = path_length;
-               state->cwd = (char *) realloc(state->cwd, state->cwd_length+1);
+               tmp = realloc(state->cwd, state->cwd_length+1);
+               if (tmp == NULL) {
+#if VIRTUAL_CWD_DEBUG
+                       fprintf (stderr, "Out of memory\n");
+#endif
+                       return 1;
+               }
+               state->cwd = (char *) tmp;
+
                memcpy(state->cwd, resolved_path, state->cwd_length+1);
                ret = 0;
        }