Skip to content

Commit 599d7a3

Browse files
committed
Fix bug #68706 - uninitalized pointer in mbstring
1 parent df4aaa8 commit 599d7a3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ext/mbstring/mbstring.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
38903890
size_t icnt;
38913891
int state = 0;
38923892
int crlf_state = -1;
3893-
char *token;
3893+
char *token = NULL;
38943894
size_t token_pos;
38953895
zend_string *fld_name, *fld_val;
38963896

@@ -3917,8 +3917,9 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
39173917
}
39183918

39193919
if (state == 0 || state == 1) {
3920-
fld_name = zend_string_init(token, token_pos, 0);
3921-
3920+
if(token) {
3921+
fld_name = zend_string_init(token, token_pos, 0);
3922+
}
39223923
state = 2;
39233924
} else {
39243925
token_pos++;
@@ -3982,7 +3983,9 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
39823983

39833984
case 3:
39843985
if (crlf_state == -1) {
3985-
fld_val = zend_string_init(token, token_pos, 0);
3986+
if(token) {
3987+
fld_val = zend_string_init(token, token_pos, 0);
3988+
}
39863989

39873990
if (fld_name != NULL && fld_val != NULL) {
39883991
zval val;
@@ -4029,8 +4032,9 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
40294032
state = 3;
40304033
}
40314034
if (state == 3) {
4032-
fld_val = zend_string_init(token, 0, 0);
4033-
4035+
if(token) {
4036+
fld_val = zend_string_init(token, token_pos, 0);
4037+
}
40344038
if (fld_name != NULL && fld_val != NULL) {
40354039
zval val;
40364040
/* FIXME: some locale free implementation is

0 commit comments

Comments
 (0)