htex

simple incorrect html parser
git clone git://git.relim.de/htex.git
Log | Files | Refs | README

commit 82a1932446c5a97096f43bca13fe06ea2ae169f7
parent f0e7578992f487aa0c587c9373aef11410a0b222
Author: Robin <kroekerrobin@gmail.com>
Date:   Sun, 16 Feb 2025 19:02:28 +0100

Add NULL pointer checks

Diffstat:
MMakefile | 2+-
Msrc/html.c | 8++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,7 +4,7 @@ MANPREFIX = $(PREFIX)/share/man all: $(CC) -O -pedantic -Werror -Wall -o htex src/misc.c src/html.c htex.c -lgrapheme debug: - $(CC) -fsanitize=address -O -pedantic -Werror -Wall -o htex src/misc.c src/html.c htex.c -lgrapheme + $(CC) -g -pedantic -Werror -Wall -o htex src/misc.c src/html.c htex.c -lgrapheme clean: rm htex install: all diff --git a/src/html.c b/src/html.c @@ -166,11 +166,11 @@ static inline bool ascii_is_whitespace(uint_least32_t cp) static bool find_opts_exist(struct FindOpts *opts) { - if (strlen(opts->tag) > 0) + if (opts->tag && strlen(opts->tag) > 0) return true; - if (strlen(opts->attr) > 0) + if (opts->attr && strlen(opts->attr) > 0) return true; - if (strlen(opts->key) > 0) + if (opts->key && strlen(opts->key) > 0) return true; return false; } @@ -538,7 +538,7 @@ static void tag_find(struct Tag *tag, struct FindOpts *opts, struct TagList *fou } if (!string_is_empty(opts->attr)) { for (int i=0; i<tag->attrs_len; i++) { - if (strcmp(tag->attrs[i]->value, opts->attr) == 0) + if (tag->attrs[i]->value && strcmp(tag->attrs[i]->value, opts->attr) == 0) matches_attr_value = true; } }