glsl: Add missing null check in push_back()
Report memory error on realloc failure and don't leak any memory. Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
committed by
Ville Syrjälä
parent
088da3720f
commit
568c545b7e
@@ -54,9 +54,18 @@ namespace {
|
||||
|
||||
void push_back(unsigned id, ir_variable *var)
|
||||
{
|
||||
counters = (active_atomic_counter *)
|
||||
realloc(counters, sizeof(active_atomic_counter) * (num_counters + 1));
|
||||
active_atomic_counter *new_counters;
|
||||
|
||||
new_counters = (active_atomic_counter *)
|
||||
realloc(counters, sizeof(active_atomic_counter) *
|
||||
(num_counters + 1));
|
||||
|
||||
if (new_counters == NULL) {
|
||||
_mesa_error_no_memory(__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
counters = new_counters;
|
||||
counters[num_counters].id = id;
|
||||
counters[num_counters].var = var;
|
||||
num_counters++;
|
||||
|
||||
Reference in New Issue
Block a user