From 5dac046f2f8ae3a20ae2ade85878dbd0b1869d33 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 17 Mar 2025 17:52:35 -0700 Subject: [PATCH] contrib/elfparser: be a bit more defensive Related: #139 --- contrib/elfparser/elfparser.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/elfparser/elfparser.c b/contrib/elfparser/elfparser.c index 58f1cec3..31a4c0cf 100644 --- a/contrib/elfparser/elfparser.c +++ b/contrib/elfparser/elfparser.c @@ -160,11 +160,17 @@ find_section (ElfParser *parser, { guint i; + if (name == NULL) + return NULL; + for (i = 0; i < parser->n_sections; ++i) { Section *section = parser->sections[i]; - if (strcmp (section->name, name) == 0 && section->type == type) + if (section->name == NULL || section->type != type) + continue; + + if (strcmp (section->name, name) == 0) return section; }