fix: add null check for parent pointer in option handling (false positive) - webdump - HTML to plain-text converter for webpages
HTML git clone git://git.codemadness.org/webdump
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 0d7d55bb8633594c343e92e3a77d34b2b4249374
DIR parent bc810c876a5d5de1e71796e5579b0c966ca092fd
HTML Author: andrew <sourcehut@lewman.us>
Date: Mon, 9 Mar 2026 12:17:36 -0700
fix: add null check for parent pointer in option handling (false positive)
Prevent null pointer dereference when an <option> tag appears at root
level without a parent <select> element. The code assumed parent would
always exist when processing DisplayOption tags, but malformed or
invalid HTML could have orphan <option> tags at the root level.
Found by Clang static analyzer (core.NullDereference warning).
Added note: this cannot be triggered, because curnode cannot be 0 here and
parent is set (non-NULL). But it should be checked nonetheless.
Diffstat:
M webdump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
DIR diff --git a/webdump.c b/webdump.c
@@ -2091,7 +2091,7 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
}
/* <select><option> */
- if (cur->tag.displaytype & DisplayOption) {
+ if (cur->tag.displaytype & DisplayOption && parent) {
/* <select multiple>: show all options */
if (parent->tag.displaytype & DisplaySelectMulti)
cur->tag.displaytype |= DisplayBlock;