Avoid null pointer dereference in grib_expression_free(). #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems grib_arguments::expression can be null.
Call stack leading to the crash is as follow. (grib_context.c is modified outside of this pull request. So line numbers may not match there.)
grib_dump -O /home/suzuki/src/eccodes-orig/build/share/eccodes/samples/reduced_gg_pl_48_grib2.tmpl
==673984== Process terminating with default action of signal 11 (SIGSEGV)
==673984== Access not within mapped region at address 0x0
==673984== at 0x4A6B42E: grib_expression_free (grib_expression.c:92)
==673984== by 0x4A6B7AB: grib_arguments_free (grib_expression.c:162)
==673984== by 0x4A6B794: grib_arguments_free (grib_expression.c:161)
==673984== by 0x4A6B794: grib_arguments_free (grib_expression.c:161)
==673984== by 0x4A6B794: grib_arguments_free (grib_expression.c:161)
==673984== by 0x4A6B794: grib_arguments_free (grib_expression.c:161)
==673984== by 0x4A6B794: grib_arguments_free (grib_expression.c:161)
==673984== by 0x494C3AE: destroy (action_class_gen.c:212)
==673984== by 0x494AC7B: grib_action_delete (action.c:127)
==673984== by 0x4A20384: grib_context_reset (grib_context.c:798)
==673984== by 0x4A20602: grib_context_delete (grib_context.c:866)
==673984== by 0x4A1F175: eccodes_module_destructor (grib_context.c:375)