Skip to content

Commit 339b0af

Browse files
committed
Avoid misc uninitialized variable warnings
1 parent 3d9c480 commit 339b0af

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

Zend/zend_compile.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,7 +4757,7 @@ void zend_compile_switch(zend_ast *ast) /* {{{ */
47574757

47584758
znode expr_node, case_node;
47594759
zend_op *opline;
4760-
uint32_t *jmpnz_opnums, opnum_default_jmp, opnum_switch;
4760+
uint32_t *jmpnz_opnums, opnum_default_jmp, opnum_switch = (uint32_t)-1;
47614761
zend_uchar jumptable_type;
47624762
HashTable *jumptable = NULL;
47634763

@@ -4850,6 +4850,7 @@ void zend_compile_switch(zend_ast *ast) /* {{{ */
48504850
zend_update_jump_target_to_next(opnum_default_jmp);
48514851

48524852
if (jumptable) {
4853+
ZEND_ASSERT(opnum_switch != (uint32_t)-1);
48534854
opline = &CG(active_op_array)->opcodes[opnum_switch];
48544855
opline->extended_value = get_next_op_number();
48554856
}
@@ -4942,12 +4943,11 @@ void zend_compile_try(zend_ast *ast) /* {{{ */
49424943
zend_bool is_last_catch = (i + 1 == catches->children);
49434944

49444945
uint32_t *jmp_multicatch = safe_emalloc(sizeof(uint32_t), classes->children - 1, 0);
4945-
uint32_t opnum_catch;
4946+
uint32_t opnum_catch = (uint32_t)-1;
49464947

49474948
CG(zend_lineno) = catch_ast->lineno;
49484949

49494950
for (j = 0; j < classes->children; j++) {
4950-
49514951
zend_ast *class_ast = classes->child[j];
49524952
zend_bool is_last_class = (j + 1 == classes->children);
49534953

@@ -4997,6 +4997,7 @@ void zend_compile_try(zend_ast *ast) /* {{{ */
49974997
jmp_opnums[i + 1] = zend_emit_jump(0);
49984998
}
49994999

5000+
ZEND_ASSERT(opnum_catch != (uint32_t)-1 && "Should have at least one class");
50005001
opline = &CG(active_op_array)->opcodes[opnum_catch];
50015002
if (!is_last_catch) {
50025003
opline->op2.opline_num = get_next_op_number();

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,7 +3076,7 @@ PHP_FUNCTION(mb_strimwidth)
30763076
{
30773077
char *str, *trimmarker = NULL;
30783078
zend_string *encoding = NULL;
3079-
zend_long from, width, swidth;
3079+
zend_long from, width, swidth = 0;
30803080
size_t str_len, trimmarker_len;
30813081
mbfl_string string, result, marker, *ret;
30823082

ext/opcache/Optimizer/scdf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) {
158158
/* Zero length blocks don't have a last instruction that would normally do this */
159159
scdf_mark_edge_feasible(scdf, i, block->successors[0]);
160160
} else {
161-
zend_op *opline;
161+
zend_op *opline = NULL;
162162
int j, end = block->start + block->len;
163163
for (j = block->start; j < end; j++) {
164164
opline = &scdf->op_array->opcodes[j];
@@ -170,6 +170,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) {
170170
if (block->successors_count == 1) {
171171
scdf_mark_edge_feasible(scdf, i, block->successors[0]);
172172
} else if (block->successors_count > 1) {
173+
ZEND_ASSERT(opline && "Should have opline in non-empty block");
173174
if (opline->opcode == ZEND_OP_DATA) {
174175
opline--;
175176
j--;

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags,
533533
int i, j;
534534
zend_op *opline, *end;
535535
int *tmp = NULL;
536-
ALLOCA_FLAG(use_heap);
536+
ALLOCA_FLAG(use_heap = 0);
537537

538538
// FIXME: Can we optimize this copying out in some cases?
539539
if (blocks[n].next_child >= 0) {

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
13701370
{
13711371
zend_long how = PDO_FETCH_USE_DEFAULT;
13721372
zval data, *return_all;
1373-
zval *arg2;
1373+
zval *arg2 = NULL;
13741374
zend_class_entry *old_ce;
13751375
zval old_ctor_args, *ctor_args = NULL;
13761376
int error = 0, flags, old_arg_count;

ext/sqlite3/sqlite3.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,11 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in
865865
zval retval;
866866
int ret;
867867

868+
// Exception occurred on previous callback. Don't attempt to call function.
869+
if (EG(exception)) {
870+
return 0;
871+
}
872+
868873
collation->fci.fci.size = (sizeof(collation->fci.fci));
869874
ZVAL_COPY_VALUE(&collation->fci.fci.function_name, &collation->cmp_func);
870875
collation->fci.fci.object = NULL;
@@ -876,13 +881,8 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in
876881

877882
collation->fci.fci.params = zargs;
878883

879-
if (!EG(exception)) {
880-
//Exception occurred on previous callback. Don't attempt to call function
881-
if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) {
882-
php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback");
883-
}
884-
} else {
885-
ZVAL_UNDEF(&retval);
884+
if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) {
885+
php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback");
886886
}
887887

888888
zval_ptr_dtor(&zargs[0]);

ext/standard/streamsfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ PHP_FUNCTION(stream_socket_enable_crypto)
14881488
zend_long cryptokind = 0;
14891489
zval *zstream, *zsessstream = NULL;
14901490
php_stream *stream, *sessstream = NULL;
1491-
zend_bool enable, cryptokindnull;
1491+
zend_bool enable, cryptokindnull = 1;
14921492
int ret;
14931493

14941494
ZEND_PARSE_PARAMETERS_START(2, 4)
@@ -1502,7 +1502,7 @@ PHP_FUNCTION(stream_socket_enable_crypto)
15021502
php_stream_from_zval(stream, zstream);
15031503

15041504
if (enable) {
1505-
if (ZEND_NUM_ARGS() < 3 || cryptokindnull) {
1505+
if (cryptokindnull) {
15061506
zval *val;
15071507

15081508
if (!GET_CTX_OPT(stream, "ssl", "crypto_method", val)) {

ext/standard/string.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5029,7 +5029,6 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
50295029
uint8_t state = 0;
50305030
size_t pos;
50315031
char *allow_free = NULL;
5032-
const char *allow_actual;
50335032
char is_xml = 0;
50345033

50355034
buf = estrndup(rbuf, len);
@@ -5040,7 +5039,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
50405039
br = 0;
50415040
if (allow) {
50425041
allow_free = zend_str_tolower_dup_ex(allow, allow_len);
5043-
allow_actual = allow_free ? allow_free : allow;
5042+
allow = allow_free ? allow_free : allow;
50445043
tbuf = emalloc(PHP_TAG_BUF_SIZE + 1);
50455044
tp = tbuf;
50465045
} else {
@@ -5145,7 +5144,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
51455144
}
51465145
*(tp++) = '>';
51475146
*tp='\0';
5148-
if (php_tag_find(tbuf, tp-tbuf, allow_actual)) {
5147+
if (php_tag_find(tbuf, tp-tbuf, allow)) {
51495148
memcpy(rp, tbuf, tp-tbuf);
51505149
rp += tp-tbuf;
51515150
}
@@ -5339,11 +5338,11 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
53395338
*rp = '\0';
53405339
}
53415340
efree((void *)buf);
5342-
if (allow) {
5341+
if (tbuf) {
53435342
efree(tbuf);
5344-
if (allow_free) {
5345-
efree(allow_free);
5346-
}
5343+
}
5344+
if (allow_free) {
5345+
efree(allow_free);
53475346
}
53485347
if (stateptr)
53495348
*stateptr = state;

0 commit comments

Comments
 (0)