diff --git a/src/markup.c b/src/markup.c
index dba630f..75372a8 100644
--- a/src/markup.c
+++ b/src/markup.c
@@ -14,7 +14,8 @@
static char *markup_quote(char *str)
{
- assert(str);
+ if (!str)
+ return NULL;
str = string_replace_all("&", "&", str);
str = string_replace_all("\"", """, str);
@@ -27,7 +28,8 @@ static char *markup_quote(char *str)
static char *markup_unquote(char *str)
{
- assert(str);
+ if (!str)
+ return NULL;
str = string_replace_all(""", "\"", str);
str = string_replace_all("'", "'", str);
@@ -40,7 +42,8 @@ static char *markup_unquote(char *str)
static char *markup_br2nl(char *str)
{
- assert(str);
+ if (!str)
+ return NULL;
str = string_replace_all("
", "\n", str);
str = string_replace_all("
", "\n", str);
@@ -57,6 +60,7 @@ static char *markup_br2nl(char *str)
*/
void markup_strip_a(char **str, char **urls)
{
+ assert(*str);
char *tag1 = NULL;
if (urls)
diff --git a/src/utils.c b/src/utils.c
index ef29cee..d185662 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -13,6 +13,9 @@
char *string_replace_char(char needle, char replacement, char *haystack)
{
+ if (!haystack)
+ return NULL;
+
char *current = haystack;
while ((current = strchr(current, needle)))
*current++ = replacement;
@@ -21,6 +24,9 @@ char *string_replace_char(char needle, char replacement, char *haystack)
char *string_replace_at(char *buf, int pos, int len, const char *repl)
{
+ assert(buf);
+ assert(repl);
+
char *tmp;
int size, buf_len, repl_len;
@@ -47,6 +53,11 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl)
char *string_replace_all(const char *needle, const char *replacement, char *haystack)
{
+ if (!haystack)
+ return NULL;
+ assert(needle);
+ assert(replacement);
+
char *start;
int needle_pos;
int needle_len, repl_len;
@@ -106,6 +117,8 @@ char *string_strip_quotes(const char *value)
void string_strip_delimited(char *str, char a, char b)
{
+ assert(str);
+
int iread=-1, iwrite=0, copen=0;
while (str[++iread] != 0) {
if (str[iread] == a) {