[Mesa-dev] [PATCH 6/6] nir: check malloc return value in print_block()
Kenneth Graunke
kenneth at whitecape.org
Mon Jan 26 01:22:57 PST 2015
On Monday, January 26, 2015 11:07:51 AM Juha-Pekka Heikkila wrote:
> 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) {
The NULL check is fine, but I don't see any reason for the shader printer to
throw an OpenGL error. It's debugging code triggered by driver environment
variables; it isn't related to any API call the application made.
--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150126/a84293e9/attachment.sig>
More information about the mesa-dev
mailing list