From 0840eaec7bf56740029aae614e393f8cf76f6946 Mon Sep 17 00:00:00 2001 From: Joseph Bisch Date: Wed, 18 Oct 2017 14:52:04 -0400 Subject: Make split functions return an array with NULL instead of NULL This avoids undefined behavior in functions that call these split functions and expect an array back instead of just a NULL pointer. --- src/irc/core/irc-servers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/irc') diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 3117e345..4eaab712 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -116,11 +116,14 @@ static char **split_line(const SERVER_REC *server, const char *line, * the code much simpler. It's worth it. */ len -= strlen(recoded_start) + strlen(recoded_end); + g_warn_if_fail(len > 0); if (len <= 0) { /* There is no room for anything. */ g_free(recoded_start); g_free(recoded_end); - return NULL; + lines = g_new(char *, 1); + lines[0] = NULL; + return lines; } lines = recode_split(server, line, target, len, onspace); -- cgit v1.2.3