@@ -710,17 +710,16 @@ PHP_METHOD(Phar, webPhar)
710
710
return ;
711
711
default :
712
712
zend_throw_exception_ex (phar_ce_PharException , 0 , "phar error: rewrite callback must return a string or false" );
713
- goto cleanup_fail ;
714
- }
715
713
716
714
cleanup_fail :
717
- zval_ptr_dtor (& params );
718
- if (free_pathinfo ) {
719
- efree (path_info );
715
+ zval_ptr_dtor (& params );
716
+ if (free_pathinfo ) {
717
+ efree (path_info );
718
+ }
719
+ efree (entry );
720
+ efree (pt );
721
+ RETURN_THROWS ();
720
722
}
721
- efree (entry );
722
- efree (pt );
723
- RETURN_THROWS ();
724
723
}
725
724
726
725
if (entry_len ) {
@@ -2840,27 +2839,26 @@ PHP_METHOD(Phar, setStub)
2840
2839
zend_long len = -1 ;
2841
2840
php_stream * stream ;
2842
2841
2843
- if ( zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "r|l" , & zstub , & len ) == SUCCESS ) {
2842
+ PHAR_ARCHIVE_OBJECT ();
2844
2843
2845
- PHAR_ARCHIVE_OBJECT ();
2844
+ if (PHAR_G (readonly ) && !phar_obj -> archive -> is_data ) {
2845
+ zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2846
+ "Cannot change stub, phar is read-only" );
2847
+ RETURN_THROWS ();
2848
+ }
2846
2849
2847
- if (PHAR_G (readonly ) && !phar_obj -> archive -> is_data ) {
2850
+ if (phar_obj -> archive -> is_data ) {
2851
+ if (phar_obj -> archive -> is_tar ) {
2848
2852
zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2849
- "Cannot change stub, phar is read-only" );
2850
- RETURN_THROWS ();
2851
- }
2852
-
2853
- if (phar_obj -> archive -> is_data ) {
2854
- if (phar_obj -> archive -> is_tar ) {
2855
- zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2856
- "A Phar stub cannot be set in a plain tar archive" );
2857
- } else {
2858
- zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2859
- "A Phar stub cannot be set in a plain zip archive" );
2860
- }
2861
- RETURN_THROWS ();
2853
+ "A Phar stub cannot be set in a plain tar archive" );
2854
+ } else {
2855
+ zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2856
+ "A Phar stub cannot be set in a plain zip archive" );
2862
2857
}
2858
+ RETURN_THROWS ();
2859
+ }
2863
2860
2861
+ if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "r|l" , & zstub , & len ) == SUCCESS ) {
2864
2862
if ((php_stream_from_zval_no_verify (stream , zstub )) != NULL ) {
2865
2863
if (len > 0 ) {
2866
2864
len = - len ;
@@ -2882,26 +2880,6 @@ PHP_METHOD(Phar, setStub)
2882
2880
"Cannot change stub, unable to read from input stream" );
2883
2881
}
2884
2882
} else if (zend_parse_parameters (ZEND_NUM_ARGS (), "s" , & stub , & stub_len ) == SUCCESS ) {
2885
-
2886
- PHAR_ARCHIVE_OBJECT ();
2887
-
2888
- if (PHAR_G (readonly ) && !phar_obj -> archive -> is_data ) {
2889
- zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2890
- "Cannot change stub, phar is read-only" );
2891
- RETURN_THROWS ();
2892
- }
2893
-
2894
- if (phar_obj -> archive -> is_data ) {
2895
- if (phar_obj -> archive -> is_tar ) {
2896
- zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2897
- "A Phar stub cannot be set in a plain tar archive" );
2898
- } else {
2899
- zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
2900
- "A Phar stub cannot be set in a plain zip archive" );
2901
- }
2902
- RETURN_THROWS ();
2903
- }
2904
-
2905
2883
if (phar_obj -> archive -> is_persistent && FAILURE == phar_copy_on_write (& (phar_obj -> archive ))) {
2906
2884
zend_throw_exception_ex (phar_ce_PharException , 0 , "phar \"%s\" is persistent, unable to copy on write" , phar_obj -> archive -> fname );
2907
2885
RETURN_THROWS ();
@@ -3752,13 +3730,13 @@ PHP_METHOD(Phar, offsetUnset)
3752
3730
size_t fname_len ;
3753
3731
phar_entry_info * entry ;
3754
3732
3733
+ PHAR_ARCHIVE_OBJECT ();
3734
+
3755
3735
if (PHAR_G (readonly ) && !phar_obj -> archive -> is_data ) {
3756
3736
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "Write operations disabled by the php.ini setting phar.readonly" );
3757
3737
RETURN_THROWS ();
3758
3738
}
3759
3739
3760
- PHAR_ARCHIVE_OBJECT ();
3761
-
3762
3740
if (zend_parse_parameters (ZEND_NUM_ARGS (), "p" , & fname , & fname_len ) == FAILURE ) {
3763
3741
RETURN_THROWS ();
3764
3742
}
@@ -4322,14 +4300,13 @@ PHP_METHOD(Phar, extractTo)
4322
4300
int ret ;
4323
4301
zval * zval_file ;
4324
4302
HashTable * files_ht = NULL ;
4325
- zend_string * files_str = NULL ;
4326
4303
zend_bool overwrite = 0 ;
4327
4304
char * error = NULL ;
4328
4305
4329
4306
ZEND_PARSE_PARAMETERS_START (1 , 3 )
4330
4307
Z_PARAM_PATH (pathto , pathto_len )
4331
- Z_PARAM_STR_OR_ARRAY_HT_OR_NULL (files_str , files_ht )
4332
- Z_PARAM_bool (overwrite )
4308
+ Z_PARAM_STR_OR_ARRAY_HT_OR_NULL (filename , files_ht )
4309
+ Z_PARAM_BOOL (overwrite )
4333
4310
ZEND_PARSE_PARAMETERS_END ();
4334
4311
4335
4312
PHAR_ARCHIVE_OBJECT ();
@@ -4371,9 +4348,7 @@ PHP_METHOD(Phar, extractTo)
4371
4348
RETURN_THROWS ();
4372
4349
}
4373
4350
4374
- if (files_str ) {
4375
- filename = files_str ;
4376
- } else if (files_ht ) {
4351
+ if (files_ht ) {
4377
4352
if (zend_hash_num_elements (files_ht ) == 0 ) {
4378
4353
RETURN_FALSE ;
4379
4354
}
@@ -4399,8 +4374,6 @@ PHP_METHOD(Phar, extractTo)
4399
4374
}
4400
4375
} ZEND_HASH_FOREACH_END ();
4401
4376
RETURN_TRUE ;
4402
- } else {
4403
- filename = NULL ;
4404
4377
}
4405
4378
4406
4379
ret = extract_helper (phar_obj -> archive , filename , pathto , pathto_len , overwrite , & error );
0 commit comments