summaryrefslogtreecommitdiff
path: root/src/core/core-doc.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-25 00:18:30 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-25 20:59:25 +0200
commite73bff95fa4bcc0902b65263bd47ec8bdc0c1128 (patch)
treed08516ff949e2b7427e8014e5424793540195bf3 /src/core/core-doc.c
parentb56b34711dfb3bacee31265e4aa28f3c1d2a7bab (diff)
downloadweechat-e73bff95fa4bcc0902b65263bd47ec8bdc0c1128.zip
core: remove check of NULL pointers before calling free() (issue #865)
Diffstat (limited to 'src/core/core-doc.c')
-rw-r--r--src/core/core-doc.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/core/core-doc.c b/src/core/core-doc.c
index 655a295c9..1b6095a7f 100644
--- a/src/core/core-doc.c
+++ b/src/core/core-doc.c
@@ -67,12 +67,8 @@ char *
doc_gen_escape_table (const char *message)
{
index_string_escaped = (index_string_escaped + 1) % 32;
-
- if (string_escaped[index_string_escaped])
- free (string_escaped[index_string_escaped]);
-
+ free (string_escaped[index_string_escaped]);
string_escaped[index_string_escaped] = string_replace (message, "|", "\\|");
-
return string_escaped[index_string_escaped];
}
@@ -89,15 +85,10 @@ doc_gen_escape_anchor_link (const char *message)
return NULL;
index_string_escaped = (index_string_escaped + 1) % 32;
-
- if (string_escaped[index_string_escaped])
- free (string_escaped[index_string_escaped]);
-
+ free (string_escaped[index_string_escaped]);
string_escaped[index_string_escaped] = string_replace_regex (
message, &regex, "-", '$', NULL, NULL);
-
regfree (&regex);
-
return string_escaped[index_string_escaped];
}
@@ -567,8 +558,7 @@ doc_gen_user_options (const char *path, const char *lang)
if (ptr_option->type == CONFIG_OPTION_TYPE_STRING)
{
tmp = string_replace (default_value, "\"", "\\\"");
- if (default_value)
- free (default_value);
+ free (default_value);
default_value = tmp;
}
string_fprintf (
@@ -578,12 +568,9 @@ doc_gen_user_options (const char *path, const char *lang)
(ptr_option->type == CONFIG_OPTION_TYPE_STRING) ? "\"" : "",
default_value,
(ptr_option->type == CONFIG_OPTION_TYPE_STRING) ? "\"" : "");
- if (desc_escaped)
- free (desc_escaped);
- if (values)
- free (values);
- if (default_value)
- free (default_value);
+ free (desc_escaped);
+ free (values);
+ free (default_value);
}
if (old_config)
@@ -1386,8 +1373,7 @@ doc_gen_api_url_options (const char *path, const char *lang)
"| %s | %s |",
ESCAPE_TABLE(name),
ESCAPE_TABLE(url_type_string[url_options[i].type]));
- if (name)
- free (name);
+ free (name);
if (url_options[i].constants)
{
for (j = 0; url_options[i].constants[j].name; j++)
@@ -1396,8 +1382,7 @@ doc_gen_api_url_options (const char *path, const char *lang)
string_fprintf (file, ",");
constant = string_tolower (url_options[i].constants[j].name);
string_fprintf (file, " %s", constant);
- if (constant)
- free (constant);
+ free (constant);
}
}
string_fprintf (file, "\n");
@@ -1787,8 +1772,7 @@ doc_generate (const char *path)
end:
for (i = 0; i < 32; i++)
{
- if (string_escaped[i])
- free (string_escaped[i]);
+ free (string_escaped[i]);
}
return rc_doc_gen;
}