summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2009-10-19 23:41:14 +0000
committerPierre Joye <pajoye@php.net>2009-10-19 23:41:14 +0000
commit5e0f3731acd7ffa487b48237d669477624ea3125 (patch)
tree8708b6e89705995320df9e126124c493a6702560 /TSRM
parent0304ec790071904bb771bb80edb5bace89472710 (diff)
downloadphp-git-5e0f3731acd7ffa487b48237d669477624ea3125.tar.gz
- MFH: fix realloc usage
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_virtual_cwd.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index ac60da0391..3e98a5acc1 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -983,6 +983,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) {
@@ -1127,7 +1128,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);
@@ -1139,7 +1149,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;
}