From: Ben Pfaff Date: Sun, 7 Feb 2021 03:52:24 +0000 (-0800) Subject: spvbin-helpers: Properly handle parsing strings with no destination. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78a43b3fd07c601dea27f0568727f515d39a2153;p=pspp spvbin-helpers: Properly handle parsing strings with no destination. binary-parser-generator will pass a null pointer to spvbin_parse_string() or spvbin_parse_bestring() for a string that should be parsed but not stored. In such a case, the implementation would dereference a null pointer. This fixes the problem. This is only a theoretical problem because the grammars PSPP uses now always store the strings that they parse. Found by cppcheck. Reported by John Darrington. --- diff --git a/src/output/spv/spvbin-helpers.c b/src/output/spv/spvbin-helpers.c index 138e213957..53ea5d4ac4 100644 --- a/src/output/spv/spvbin-helpers.c +++ b/src/output/spv/spvbin-helpers.c @@ -180,7 +180,8 @@ spvbin_parse_string__ (struct spvbin_input *input, uint32_t (*raw_to_native32) (uint32_t), char **p) { - *p = NULL; + if (p) + *p = NULL; uint32_t length; if (input->size - input->ofs < sizeof length)