Skip to content

Commit c210c68

Browse files
author
Moriyoshi Koizumi
committed
- Add more null checks.
1 parent 3e026f0 commit c210c68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ext/standard/filters.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ typedef enum _php_conv_err_t {
307307
PHP_CONV_ERR_INVALID_SEQ,
308308
PHP_CONV_ERR_UNEXPECTED_EOS,
309309
PHP_CONV_ERR_EXISTS,
310+
PHP_CONV_ERR_ALLOC,
310311
PHP_CONV_ERR_NOT_FOUND
311312
} php_conv_err_t;
312313

@@ -1167,13 +1168,20 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr
11671168
if (zend_hash_find((HashTable *)ht, field_name, field_name_len, (void **)&tmpval) == SUCCESS) {
11681169
if (Z_TYPE_PP(tmpval) != IS_STRING) {
11691170
zval zt = **tmpval;
1171+
11701172
convert_to_string(&zt);
1171-
*pretval = pemalloc(Z_STRLEN(zt) + 1, persistent);
1173+
1174+
if (NULL == (*pretval = pemalloc(Z_STRLEN(zt) + 1, persistent))) {
1175+
return PHP_CONV_ERR_ALLOC;
1176+
}
1177+
11721178
*pretval_len = Z_STRLEN(zt);
11731179
memcpy(*pretval, Z_STRVAL(zt), Z_STRLEN(zt) + 1);
11741180
zval_dtor(&zt);
11751181
} else {
1176-
*pretval = pemalloc(Z_STRLEN_PP(tmpval) + 1, persistent);
1182+
if (NULL == (*pretval = pemalloc(Z_STRLEN_PP(tmpval) + 1, persistent))) {
1183+
return PHP_CONV_ERR_ALLOC;
1184+
}
11771185
*pretval_len = Z_STRLEN_PP(tmpval);
11781186
memcpy(*pretval, Z_STRVAL_PP(tmpval), Z_STRLEN_PP(tmpval) + 1);
11791187
}

0 commit comments

Comments
 (0)