@@ -1014,7 +1014,7 @@ static void php_zip_object_free_storage(zend_object *object) /* {{{ */
10141014
10151015 if (intern -> buffers_cnt > 0 ) {
10161016 for (i = 0 ; i < intern -> buffers_cnt ; i ++ ) {
1017- efree (intern -> buffers [i ]);
1017+ zend_string_release (intern -> buffers [i ]);
10181018 }
10191019 efree (intern -> buffers );
10201020 }
@@ -1868,17 +1868,16 @@ PHP_METHOD(ZipArchive, addFromString)
18681868
18691869 ze_obj = Z_ZIP_P (self );
18701870 if (ze_obj -> buffers_cnt ) {
1871- ze_obj -> buffers = ( char * * ) safe_erealloc (ze_obj -> buffers , sizeof (char * ), (ze_obj -> buffers_cnt + 1 ), 0 );
1871+ ze_obj -> buffers = safe_erealloc (ze_obj -> buffers , sizeof (* ze_obj -> buffers ), (ze_obj -> buffers_cnt + 1 ), 0 );
18721872 pos = ze_obj -> buffers_cnt ++ ;
18731873 } else {
1874- ze_obj -> buffers = ( char * * ) emalloc (sizeof (char * ));
1874+ ze_obj -> buffers = emalloc (sizeof (* ze_obj -> buffers ));
18751875 ze_obj -> buffers_cnt ++ ;
18761876 pos = 0 ;
18771877 }
1878- ze_obj -> buffers [pos ] = (char * )safe_emalloc (ZSTR_LEN (buffer ), 1 , 1 );
1879- memcpy (ze_obj -> buffers [pos ], ZSTR_VAL (buffer ), ZSTR_LEN (buffer ) + 1 );
1878+ ze_obj -> buffers [pos ] = zend_string_copy (buffer );
18801879
1881- zs = zip_source_buffer (intern , ze_obj -> buffers [ pos ] , ZSTR_LEN (buffer ), 0 );
1880+ zs = zip_source_buffer (intern , ZSTR_VAL ( buffer ) , ZSTR_LEN (buffer ), 0 );
18821881
18831882 if (zs == NULL ) {
18841883 RETURN_FALSE ;
0 commit comments