Skip to content

Commit aadd3aa

Browse files
committed
Use RETURN_THROWS() in various places
1 parent bbcfa66 commit aadd3aa

33 files changed

+84
-83
lines changed

ext/com_dotnet/com_com.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ PHP_FUNCTION(com_create_instance)
6262
ZEND_NUM_ARGS(), "sa|ls",
6363
&module_name, &module_name_len, &server_params, &cp,
6464
&typelib_name, &typelib_name_len)) {
65-
return;
65+
RETURN_THROWS();
6666
}
6767

6868
cp_it = php_win32_cp_get_by_id((DWORD)cp);
6969
if (!cp_it) {
7070
php_com_throw_exception(E_INVALIDARG, "Could not create COM object - invalid codepage!");
71-
return;
71+
RETURN_THROWS();
7272
}
7373
obj->code_page = (int)cp;
7474

@@ -116,7 +116,7 @@ PHP_FUNCTION(com_create_instance)
116116

117117
if (server_name && !COMG(allow_dcom)) {
118118
php_com_throw_exception(E_ERROR, "DCOM has been disabled by your administrator [com.allow_dcom=0]");
119-
return;
119+
RETURN_THROWS();
120120
}
121121

122122
moniker = php_com_string_to_olestring(module_name, module_name_len, obj->code_page);
@@ -231,7 +231,7 @@ PHP_FUNCTION(com_create_instance)
231231

232232
php_com_throw_exception(res, msg);
233233
efree(msg);
234-
return;
234+
RETURN_THROWS();
235235
}
236236

237237
/* we got the object and it lives ! */

ext/com_dotnet/com_dotnet.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
205205
snprintf(buf, sizeof(buf), "Failed to init .Net runtime [%s] %s", where, err);
206206
php_win32_error_msg_free(err);
207207
php_com_throw_exception(hr, buf);
208-
return;
208+
RETURN_THROWS();
209209
}
210210
stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
211211

@@ -219,7 +219,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
219219
php_win32_error_msg_free(err);
220220
php_com_throw_exception(hr, buf);
221221
ZVAL_NULL(object);
222-
return;
222+
RETURN_THROWS();
223223
}
224224

225225
where = "QI: System._AppDomain";
@@ -231,7 +231,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
231231
php_win32_error_msg_free(err);
232232
php_com_throw_exception(hr, buf);
233233
ZVAL_NULL(object);
234-
return;
234+
RETURN_THROWS();
235235
}
236236
}
237237

@@ -247,7 +247,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
247247
cp_it = php_win32_cp_get_by_id((DWORD)cp);
248248
if (!cp_it) {
249249
php_com_throw_exception(E_INVALIDARG, "Could not create .Net object - invalid codepage!");
250-
return;
250+
RETURN_THROWS();
251251
}
252252
obj->code_page = (int)cp_it->id;
253253

@@ -311,7 +311,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
311311
snprintf(buf, sizeof(buf), "Failed to instantiate .Net object [%s] [0x%08x] %s", where, hr, err);
312312
php_win32_error_msg_free(err);
313313
php_com_throw_exception(hr, buf);
314-
return;
314+
RETURN_THROWS();
315315
}
316316
}
317317
/* }}} */

ext/com_dotnet/com_persist.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream)
289289

290290
#define CPH_FETCH() php_com_persist_helper *helper = (php_com_persist_helper*)Z_OBJ_P(getThis());
291291

292-
#define CPH_NO_OBJ() if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance"); return; }
292+
#define CPH_NO_OBJ() if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance"); RETURN_THROWS(); }
293293

294294
typedef struct {
295295
zend_object std;
@@ -490,7 +490,7 @@ CPH_METHOD(GetMaxStreamSize)
490490
res = IPersistStream_GetSizeMax(helper->ips, &size);
491491
} else {
492492
php_com_throw_exception(res, NULL);
493-
return;
493+
RETURN_THROWS();
494494
}
495495
}
496496

@@ -545,13 +545,13 @@ CPH_METHOD(LoadFromStream)
545545

546546
if (stream == NULL) {
547547
php_com_throw_exception(E_INVALIDARG, "expected a stream");
548-
return;
548+
RETURN_THROWS();
549549
}
550550

551551
stm = php_com_wrapper_export_stream(stream);
552552
if (stm == NULL) {
553553
php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream");
554-
return;
554+
RETURN_THROWS();
555555
}
556556

557557
res = S_OK;
@@ -581,7 +581,7 @@ CPH_METHOD(LoadFromStream)
581581

582582
if (FAILED(res)) {
583583
php_com_throw_exception(res, NULL);
584-
RETURN_NULL();
584+
RETURN_THROWS();
585585
}
586586
}
587587
/* }}} */
@@ -606,13 +606,13 @@ CPH_METHOD(SaveToStream)
606606

607607
if (stream == NULL) {
608608
php_com_throw_exception(E_INVALIDARG, "expected a stream");
609-
return;
609+
RETURN_THROWS();
610610
}
611611

612612
stm = php_com_wrapper_export_stream(stream);
613613
if (stm == NULL) {
614614
php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream");
615-
return;
615+
RETURN_THROWS();
616616
}
617617

618618
res = get_persist_stream_init(helper);
@@ -629,7 +629,7 @@ CPH_METHOD(SaveToStream)
629629

630630
if (FAILED(res)) {
631631
php_com_throw_exception(res, NULL);
632-
return;
632+
RETURN_THROWS();
633633
}
634634

635635
RETURN_TRUE;
@@ -657,7 +657,7 @@ CPH_METHOD(__construct)
657657

658658
if (V_VT(&obj->v) != VT_DISPATCH || V_DISPATCH(&obj->v) == NULL) {
659659
php_com_throw_exception(E_INVALIDARG, "parameter must represent an IDispatch COM object");
660-
return;
660+
RETURN_THROWS();
661661
}
662662

663663
/* it is always safe to cast an interface to IUnknown */

ext/com_dotnet/com_variant.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static void variant_binary_operation(enum variant_binary_opcode op, INTERNAL_FUN
589589
php_com_variant_from_zval(vright, zright, codepage);
590590

591591
} else {
592-
return;
592+
RETURN_THROWS();
593593
}
594594

595595
switch (op) {
@@ -775,7 +775,7 @@ static void variant_unary_operation(enum variant_unary_opcode op, INTERNAL_FUNCT
775775
vleft = &left_val;
776776
php_com_variant_from_zval(vleft, zleft, codepage);
777777
} else {
778-
return;
778+
RETURN_THROWS();
779779
}
780780

781781
switch (op) {
@@ -873,7 +873,7 @@ PHP_FUNCTION(variant_round)
873873
vleft = &left_val;
874874
php_com_variant_from_zval(vleft, zleft, codepage);
875875
} else {
876-
return;
876+
RETURN_THROWS();
877877
}
878878

879879
if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) {
@@ -933,7 +933,7 @@ PHP_FUNCTION(variant_cmp)
933933
php_com_variant_from_zval(vright, zright, codepage);
934934

935935
} else {
936-
return;
936+
RETURN_THROWS();
937937
}
938938

939939
ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags));

ext/dba/dba.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
598598
/* Exception during string conversion */
599599
if (EG(exception)) {
600600
FREENOW;
601-
return;
601+
RETURN_THROWS();
602602
}
603603

604604
if (persistent) {

ext/enchant/enchant.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ PHP_FUNCTION(enchant_dict_quick_check)
660660
if (sugg) {
661661
sugg = zend_try_array_init(sugg);
662662
if (!sugg) {
663-
return;
663+
RETURN_THROWS();
664664
}
665665
}
666666

ext/ffi/ffi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,7 @@ static zend_always_inline int zend_ffi_validate_api_restriction(zend_execute_dat
27962796

27972797
#define ZEND_FFI_VALIDATE_API_RESTRICTION() do { \
27982798
if (UNEXPECTED(!zend_ffi_validate_api_restriction(execute_data))) { \
2799-
return; \
2799+
RETURN_THROWS(); \
28002800
} \
28012801
} while (0)
28022802

ext/gd/gd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
33423342
zval *SIM; \
33433343
gdImagePtr im_src; \
33443344
if (zend_parse_parameters(1, "O", &SIM, gd_image_ce) == FAILURE) { \
3345-
return; \
3345+
RETURN_THROWS(); \
33463346
} \
33473347
im_src = php_gd_libgdimageptr_from_zval_p(SIM);
33483348

ext/iconv/iconv.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -2438,8 +2438,9 @@ PHP_FUNCTION(iconv_set_encoding)
24382438
size_t type_len, retval;
24392439
zend_string *name;
24402440

2441-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &type, &type_len, &charset) == FAILURE)
2442-
return;
2441+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &type, &type_len, &charset) == FAILURE) {
2442+
RETURN_THROWS();
2443+
}
24432444

24442445
if (ZSTR_LEN(charset) >= ICONV_CSNMAXLEN) {
24452446
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);

ext/intl/idn/idn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
204204
if (idna_info != NULL) {
205205
idna_info = zend_try_array_init(idna_info);
206206
if (!idna_info) {
207-
return;
207+
RETURN_THROWS();
208208
}
209209
}
210210

ext/ldap/ldap.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ static void _php_ldap_controls_to_array(LDAP *ld, LDAPControl** ctrls, zval* arr
622622

623623
array = zend_try_array_init(array);
624624
if (!array) {
625-
return;
625+
RETURN_THROWS();
626626
}
627627

628628
if (ctrls == NULL) {
@@ -3277,7 +3277,7 @@ PHP_FUNCTION(ldap_set_option)
32773277
zend_string *val;
32783278
val = zval_get_string(newval);
32793279
if (EG(exception)) {
3280-
return;
3280+
RETURN_THROWS();
32813281
}
32823282
if (ldap_set_option(ldap, option, ZSTR_VAL(val))) {
32833283
zend_string_release(val);
@@ -3376,7 +3376,7 @@ PHP_FUNCTION(ldap_parse_result)
33763376
case 6:
33773377
referrals = zend_try_array_init(referrals);
33783378
if (!referrals) {
3379-
return;
3379+
RETURN_THROWS();
33803380
}
33813381
if (lreferrals != NULL) {
33823382
refp = lreferrals;
@@ -3559,7 +3559,7 @@ PHP_FUNCTION(ldap_parse_reference)
35593559

35603560
referrals = zend_try_array_init(referrals);
35613561
if (!referrals) {
3562-
return;
3562+
RETURN_THROWS();
35633563
}
35643564

35653565
if (lreferrals != NULL) {

ext/mbstring/mbstring.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ PHP_FUNCTION(mb_parse_str)
17501750

17511751
track_vars_array = zend_try_array_init(track_vars_array);
17521752
if (!track_vars_array) {
1753-
return;
1753+
RETURN_THROWS();
17541754
}
17551755

17561756
encstr = estrndup(encstr, encstr_len);

ext/mbstring/php_mbregex.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
903903
if (array != NULL) {
904904
array = zend_try_array_init(array);
905905
if (!array) {
906-
return;
906+
RETURN_THROWS();
907907
}
908908
}
909909

ext/oci8/oci8_interface.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ PHP_FUNCTION(oci_fetch_all)
14911491
/* Fetch by Row: array will contain one sub-array per query row */
14921492
array = zend_try_array_init(array);
14931493
if (!array) {
1494-
return;
1494+
RETURN_THROWS();
14951495
}
14961496

14971497
columns = safe_emalloc(statement->ncolumns, sizeof(php_oci_out_column *), 0);
@@ -1535,7 +1535,7 @@ PHP_FUNCTION(oci_fetch_all)
15351535
/* Fetch by columns: array will contain one sub-array per query column */
15361536
array = zend_try_array_init_size(array, statement->ncolumns);
15371537
if (!array) {
1538-
return;
1538+
RETURN_THROWS();
15391539
}
15401540

15411541
columns = safe_emalloc(statement->ncolumns, sizeof(php_oci_out_column *), 0);

ext/odbc/php_odbc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ PHP_FUNCTION(odbc_fetch_into)
16401640

16411641
pv_res_arr = zend_try_array_init(pv_res_arr);
16421642
if (!pv_res_arr) {
1643-
return;
1643+
RETURN_THROWS();
16441644
}
16451645

16461646
#ifdef HAVE_SQL_EXTENDED_FETCH

ext/pcntl/pcntl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ PHP_FUNCTION(pcntl_waitpid)
605605
if (z_rusage) {
606606
z_rusage = zend_try_array_init(z_rusage);
607607
if (!z_rusage) {
608-
return;
608+
RETURN_THROWS();
609609
}
610610

611611
memset(&rusage, 0, sizeof(struct rusage));
@@ -654,7 +654,7 @@ PHP_FUNCTION(pcntl_wait)
654654
if (z_rusage) {
655655
z_rusage = zend_try_array_init(z_rusage);
656656
if (!z_rusage) {
657-
return;
657+
RETURN_THROWS();
658658
}
659659

660660
memset(&rusage, 0, sizeof(struct rusage));
@@ -1084,7 +1084,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
10841084
if (user_oldset != NULL) {
10851085
user_oldset = zend_try_array_init(user_oldset);
10861086
if (!user_oldset) {
1087-
return;
1087+
RETURN_THROWS();
10881088
}
10891089

10901090
for (signo = 1; signo < NSIG; ++signo) {

ext/phar/phar_object.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ PHP_METHOD(Phar, buildFromDirectory)
17591759
zval_ptr_dtor(&arg);
17601760
if (EG(exception)) {
17611761
zval_ptr_dtor(&iter);
1762-
RETURN_FALSE;
1762+
RETURN_THROWS();
17631763
}
17641764

17651765
if (SUCCESS != object_init_ex(&iteriter, spl_ce_RecursiveIteratorIterator)) {
@@ -1775,7 +1775,7 @@ PHP_METHOD(Phar, buildFromDirectory)
17751775
if (EG(exception)) {
17761776
zval_ptr_dtor(&iter);
17771777
zval_ptr_dtor(&iteriter);
1778-
RETURN_FALSE;
1778+
RETURN_THROWS();
17791779
}
17801780

17811781
zval_ptr_dtor(&iter);

0 commit comments

Comments
 (0)