]> granicus.if.org Git - php/commitdiff
realloc() can return NULL
authorAnatol Belski <ab@php.net>
Mon, 23 Oct 2017 10:50:52 +0000 (12:50 +0200)
committerAnatol Belski <ab@php.net>
Mon, 23 Oct 2017 11:27:34 +0000 (13:27 +0200)
TSRM/TSRM.c

index aff1cef84e2083a9d37c3735c957b980ebf65237..76d0c820b4a75dc84363cd0723a9711ca621f5a5 100644 (file)
@@ -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;