summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_atomics.cpp
diff options
context:
space:
mode:
authorJuha-Pekka Heikkila <[email protected]>2014-05-07 12:38:07 +0300
committerVille Syrjälä <[email protected]>2014-06-26 15:37:14 +0300
commit568c545b7ee732f32656f06a953af5a0887ff6b6 (patch)
tree40d9fe3e03bae33a858e87a8c9c2bdab2893e3b7 /src/glsl/link_atomics.cpp
parent088da3720f12579c14b1f0edd6e6df6ff8b74571 (diff)
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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/link_atomics.cpp')
-rw-r--r--src/glsl/link_atomics.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
index d92cdb11709..fbe4e7364ae 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -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++;