mirror of
https://github.com/php/php-src.git
synced 2024-12-27 02:39:39 +08:00
- Simplify dtor
- Zero terminate meta data
This commit is contained in:
parent
3066cfb3ef
commit
c440902e04
@ -157,8 +157,7 @@ static void destroy_phar_manifest(void *pDest) /* {{{ */
|
|||||||
php_stream_close(entry->temp_file);
|
php_stream_close(entry->temp_file);
|
||||||
}
|
}
|
||||||
if (entry->metadata) {
|
if (entry->metadata) {
|
||||||
zval_dtor(entry->metadata);
|
zval_ptr_dtor(&entry->metadata);
|
||||||
efree(entry->metadata);
|
|
||||||
entry->metadata = 0;
|
entry->metadata = 0;
|
||||||
}
|
}
|
||||||
efree(entry->filename);
|
efree(entry->filename);
|
||||||
@ -397,12 +396,13 @@ static int phar_parse_metadata(php_stream *fp, char **buffer, char *endbuffer, z
|
|||||||
if the index already exists, convert to a sub-array */
|
if the index already exists, convert to a sub-array */
|
||||||
PHAR_GET_32(*buffer, datatype);
|
PHAR_GET_32(*buffer, datatype);
|
||||||
PHAR_GET_16(*buffer, len);
|
PHAR_GET_16(*buffer, len);
|
||||||
data = (char *) emalloc(len);
|
data = (char *) emalloc(len+1);
|
||||||
if (endbuffer - *buffer < len) {
|
if (endbuffer - *buffer < len) {
|
||||||
efree(data);
|
efree(data);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
} else {
|
} else {
|
||||||
memcpy(data, *buffer, len);
|
memcpy(data, *buffer, len);
|
||||||
|
data[len] = '\0';
|
||||||
}
|
}
|
||||||
if (SUCCESS == zend_hash_index_find(metadata->value.ht, datatype, (void**)&found)) {
|
if (SUCCESS == zend_hash_index_find(metadata->value.ht, datatype, (void**)&found)) {
|
||||||
if (Z_TYPE_P(found) == IS_ARRAY) {
|
if (Z_TYPE_P(found) == IS_ARRAY) {
|
||||||
|
Loading…
Reference in New Issue
Block a user