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

Submitted by Juha-Pekka Heikkila on Feb. 10, 2015, 11:52 a.m.

Details

Message ID 1423569161-20403-1-git-send-email-juhapekka.heikkila@gmail.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Juha-Pekka Heikkila Feb. 10, 2015, 11:52 a.m.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
 src/glsl/nir/nir_print.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index 9c07950..c250850 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -646,6 +646,9 @@  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)
+      return;
+
    struct set_entry *entry;
    unsigned i = 0;
    set_foreach(block->predecessors, entry) {

Comments

On Tuesday, February 10, 2015 01:52:41 PM Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
> ---
>  src/glsl/nir/nir_print.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
> index 9c07950..c250850 100644
> --- a/src/glsl/nir/nir_print.c
> +++ b/src/glsl/nir/nir_print.c
> @@ -646,6 +646,9 @@ 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)
> +      return;
> +
>     struct set_entry *entry;
>     unsigned i = 0;
>     set_foreach(block->predecessors, entry) {
> 

Thanks, this is better.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>