]> granicus.if.org Git - php/commitdiff
Fixed memory leak (Nuno)
authorDmitry Stogov <dmitry@php.net>
Tue, 3 Oct 2006 07:31:10 +0000 (07:31 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 3 Oct 2006 07:31:10 +0000 (07:31 +0000)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index dca5b9c56ea86e0c0fced5977593f5085c47f97b..db8157c0c5aecb14d8cc527ca8df622179e46efd 100644 (file)
@@ -2846,9 +2846,13 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
                                state.cwd_length = strlen(cwd);
                                state.cwd = zend_strndup(cwd, state.cwd_length);
 
-                               if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                   zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) {
-                                       failure_retval=1;
+                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+
+                               free(state.cwd);
+
+                               if (failure_retval) {
+                                       /* do nothing */
                                } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) {
                                        if (!file_handle.opened_path) {
                                                file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
@@ -2868,7 +2872,6 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
                                        }
                                }
-                               free(state.cwd);
                        }
                        break;
                case ZEND_INCLUDE:
index 99277f2b18f76d9a461dc176a5cb26c2904230fc..1c524cd60be1723319fe8158b2a3610545a45e2f 100644 (file)
@@ -1948,9 +1948,13 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                state.cwd_length = strlen(cwd);
                                state.cwd = zend_strndup(cwd, state.cwd_length);
 
-                               if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                   zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) {
-                                       failure_retval=1;
+                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+
+                               free(state.cwd);
+
+                               if (failure_retval) {
+                                       /* do nothing */
                                } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) {
                                        if (!file_handle.opened_path) {
                                                file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
@@ -1970,7 +1974,6 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
                                        }
                                }
-                               free(state.cwd);
                        }
                        break;
                case ZEND_INCLUDE:
@@ -4549,9 +4552,13 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                state.cwd_length = strlen(cwd);
                                state.cwd = zend_strndup(cwd, state.cwd_length);
 
-                               if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                   zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) {
-                                       failure_retval=1;
+                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+
+                               free(state.cwd);
+
+                               if (failure_retval) {
+                                       /* do nothing */
                                } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) {
                                        if (!file_handle.opened_path) {
                                                file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
@@ -4571,7 +4578,6 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
                                        }
                                }
-                               free(state.cwd);
                        }
                        break;
                case ZEND_INCLUDE:
@@ -7747,9 +7753,13 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                state.cwd_length = strlen(cwd);
                                state.cwd = zend_strndup(cwd, state.cwd_length);
 
-                               if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                   zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) {
-                                       failure_retval=1;
+                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+
+                               free(state.cwd);
+
+                               if (failure_retval) {
+                                       /* do nothing */
                                } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) {
                                        if (!file_handle.opened_path) {
                                                file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
@@ -7769,7 +7779,6 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
                                        }
                                }
-                               free(state.cwd);
                        }
                        break;
                case ZEND_INCLUDE:
@@ -20280,9 +20289,13 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                state.cwd_length = strlen(cwd);
                                state.cwd = zend_strndup(cwd, state.cwd_length);
 
-                               if (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                   zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1)) {
-                                       failure_retval=1;
+                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+
+                               free(state.cwd);
+
+                               if (failure_retval) {
+                                       /* do nothing */
                                } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &file_handle TSRMLS_CC)) {
                                        if (!file_handle.opened_path) {
                                                file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
@@ -20302,7 +20315,6 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
                                        }
                                }
-                               free(state.cwd);
                        }
                        break;
                case ZEND_INCLUDE: