From ad3be0278cda6d9e2a9be4304169b47503c070d3 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 4 Jan 2022 16:21:20 +0100 Subject: [PATCH] [string] Check for NULL --- src/util/string.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/util/string.c b/src/util/string.c index 67881b176..676276969 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -554,8 +554,13 @@ string_replace(struct string *res, struct string *inp, struct string *what, stru char *ins; char *tmp_cnt; - init_string(&tmp); - init_string(&tmp2); + if (!init_string(&tmp)) { + return; + }; + if (!init_string(&tmp2)) { + done_string(&tmp); + return; + } add_string_to_string(&tmp, inp); @@ -588,10 +593,16 @@ string_replace(struct string *res, struct string *inp, struct string *what, stru add_bytes_to_string(&tmp2,found,af_len); // clear tmp string and tmp2 string done_string(&tmp); - init_string(&tmp); + if (!init_string(&tmp)) { + done_string(&tmp2); + return; + } add_string_to_string(&tmp, &tmp2); done_string(&tmp2); - init_string(&tmp2); + if (!init_string(&tmp2)) { + done_string(&tmp); + return; + } //printf("TMP: %s |\n",tmp.source); head = tmp.source; }