com php-src: Conditionally free depending on how assignment happened: ext/openssl/openssl.c
| From: | Joe Watkins | Date: | Fri, 06 Jan 2017 15:24:37 +0000 |
| Subject: | com php-src: Conditionally free depending on how assignment happened: ext/openssl/openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96591@lists.php.net to get a copy of this message | ||
Commit: 9a0dac124e42cf5919ecbdff6ee814688a789292
Author: Leigh <leigh@php.net> Fri, 6 Jan 2017 15:24:37 +0000
Parents: 053b966134dec5bdde30da92b581be0f523c4c6b
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9a0dac124e42cf5919ecbdff6ee814688a789292
Log:
Conditionally free depending on how assignment happened
Changed paths:
M ext/openssl/openssl.c
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 5de4869..323bdcf 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -667,9 +667,9 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
}
for (i = 0; i < X509_NAME_entry_count(name); i++) {
- unsigned char *to_add;
+ unsigned char *to_add = NULL;
int to_add_len = 0;
-
+ int needs_free = 0;
ne = X509_NAME_get_entry(name, i);
obj = X509_NAME_ENTRY_get_object(ne);
@@ -684,6 +684,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
str = X509_NAME_ENTRY_get_data(ne);
if (ASN1_STRING_type(str) != V_ASN1_UTF8STRING) {
to_add_len = ASN1_STRING_to_UTF8(&to_add, str);
+ needs_free = 1;
} else {
to_add = ASN1_STRING_data(str);
to_add_len = ASN1_STRING_length(str);
@@ -704,8 +705,13 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int
s
}
}
- OPENSSL_free(to_add);
+ if (needs_free) {
+ OPENSSL_free(to_add);
+ to_add = NULL;
+ needs_free = 0;
+ }
}
+
if (key != NULL) {
zend_hash_str_update(Z_ARRVAL_P(val), key, strlen(key), &subitem);
}