[Mesa-dev] [PATCH 6/6] nir: check malloc return value in print_block()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Mon Jan 26 01:07:51 PST 2015


report error on null return value and bail out.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/glsl/nir/nir_print.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index 9c07950..79c4cd8 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -646,6 +646,11 @@ print_block(nir_block *block, print_var_state *state, unsigned tabs, FILE *fp)
    nir_block **preds =
       malloc(block->predecessors->entries * sizeof(nir_block *));
 
+   if (!preds) {
+      _mesa_error_no_memory(__func__);
+      return;
+   }
+
    struct set_entry *entry;
    unsigned i = 0;
    set_foreach(block->predecessors, entry) {
-- 
1.8.5.1



More information about the mesa-dev mailing list