diff options
author | Topi Pohjolainen <[email protected]> | 2018-04-05 10:21:01 +0300 |
---|---|---|
committer | Topi Pohjolainen <[email protected]> | 2018-04-11 01:49:56 +0300 |
commit | 5d895a1f374854a068104f07f79a24fc79110aea (patch) | |
tree | 32d278a61e0f71f04e7c4ec829c6b142b86fff56 | |
parent | 98d38747543277cf931499a6b66626ac644b1865 (diff) |
nir: Check if u_vector_init() succeeds
However, it only fails when running out of memory. Now, if we
are about to check that, we should be consistent and check
the allocation of the worklist as well.
CID: 1433512
Fixes: edb18564c7 nir: Initial implementation of a nir_instr_worklist
Reviewed-by: Thomas Helland <[email protected]>
Signed-off-by: Topi Pohjolainen <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_worklist.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_worklist.h b/src/compiler/nir/nir_worklist.h index e3769087664..3fb391fceff 100644 --- a/src/compiler/nir/nir_worklist.h +++ b/src/compiler/nir/nir_worklist.h @@ -105,8 +105,15 @@ typedef struct { static inline nir_instr_worklist * nir_instr_worklist_create() { nir_instr_worklist *wl = malloc(sizeof(nir_instr_worklist)); - u_vector_init(&wl->instr_vec, sizeof(struct nir_instr *), - sizeof(struct nir_instr *) * 8); + if (!wl) + return NULL; + + if (!u_vector_init(&wl->instr_vec, sizeof(struct nir_instr *), + sizeof(struct nir_instr *) * 8)) { + free(wl); + return NULL; + } + return wl; } |