]> granicus.if.org Git - php/commitdiff
Fixed memory leak inside array_intersec (coverity issues #403,#404)
authorIlia Alshanetsky <iliaa@php.net>
Sat, 22 Sep 2007 15:38:00 +0000 (15:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 22 Sep 2007 15:38:00 +0000 (15:38 +0000)
ext/standard/array.c

index ff5a5ef6b5fbedf05c080317d92261b4322cbefe..298e97c0b83894bb1b0b2632bfb44c0b43c575df 100644 (file)
@@ -3156,10 +3156,12 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
                                intersect_data_compare_func = array_user_compare;
                                BG(user_compare_func_name) = args[arr_argc + 1];/* data - key */
                } else {
+                       efree(args);
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_compare_type is %d. key_compare_type is %d. This should never happen. Please report as a bug.", data_compare_type, key_compare_type);
                        return;
                }               
        } else {
+               efree(args);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "behavior is %d. This should never happen. Please report as a bug", behavior);
                return;
        }
@@ -3178,6 +3180,9 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
                hash = HASH_OF(*args[i]);
                list = (Bucket **) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket *), hash->persistent);
                if (!list) {
+                       efree(args);
+                       efree(lists);
+                       efree(ptrs);
                        RETURN_FALSE;
                }
                lists[i] = list;
@@ -3612,10 +3617,12 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                        diff_data_compare_func = array_user_compare;
                        BG(user_compare_func_name) = args[arr_argc + 1];/* data - key*/
                } else {
+                       efree(args);
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_compare_type is %d. key_compare_type is %d. This should never happen. Please report as a bug", data_compare_type, key_compare_type);
                        return; 
                }                       
        } else {
+               efree(args);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "behavior is %d. This should never happen. Please report as a bug", behavior);
                return; 
        }
@@ -3634,6 +3641,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                hash = HASH_OF(*args[i]);
                list = (Bucket **) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket *), hash->persistent);
                if (!list) {
+                       efree(args);
                        efree(ptrs);
                        efree(lists);
                        RETURN_FALSE;