pajoye                                   Mon, 19 Oct 2009 23:41:14 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=289781

Log:
- MFH: fix realloc usage

Changed paths:
    U   php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c

Modified: php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c
===================================================================
--- php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c        2009-10-19 
23:38:55 UTC (rev 289780)
+++ php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c        2009-10-19 
23:41:14 UTC (rev 289781)
@@ -983,6 +983,7 @@
        time_t t;
        int ret;
        int add_slash;
+       void *tmp;
        TSRMLS_FETCH();

        if (path_length == 0 || path_length >= MAXPATHLEN-1) {
@@ -1127,7 +1128,16 @@

                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);
@@ -1139,7 +1149,15 @@
                }
        } 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;
        }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to