diff options
author | Anatol Belski <ab@php.net> | 2017-10-23 12:50:52 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-10-23 13:27:34 +0200 |
commit | 12bd998d5830882d12db2b1b6ba70890b4ede531 (patch) | |
tree | e9e5127fe98c19d4e9aff3b3d1b0e5800193ae50 /TSRM | |
parent | 979bad4ae22d7c8c9499b447d7de055d1c46add0 (diff) | |
download | php-git-12bd998d5830882d12db2b1b6ba70890b4ede531.tar.gz |
realloc() can return NULL
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/TSRM.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index aff1cef84e..76d0c820b4 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -238,13 +238,15 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate /* store the new resource type in the resource sizes table */ if (resource_types_table_size < id_count) { - resource_types_table = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count); - if (!resource_types_table) { + tsrm_resource_type *_tmp; + _tmp = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count); + if (!_tmp) { tsrm_mutex_unlock(tsmm_mutex); TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource")); *rsrc_id = 0; return 0; } + resource_types_table = _tmp; resource_types_table_size = id_count; } resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size; |