From 2c2d3a6ec34d983cb698b245facb8d6240aec1b3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 12 Mar 2022 00:42:06 +0100 Subject: [PATCH] Reject empty mood arguments. Currently we crash in mood.c due to an assertion. --- mood.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mood.c b/mood.c index a63d4d2a..d6a82923 100644 --- a/mood.c +++ b/mood.c @@ -873,10 +873,14 @@ int change_current_mood(const char *mood_name, char **errmsg) if (mood_name) { struct mood *m; struct osl_row *row; - struct osl_object obj = { - .data = (char *)mood_name, - .size = strlen(mood_name) + 1 - }; + struct osl_object obj; + + if (!*mood_name) { + *errmsg = make_message("empty mood name"); + return -ERRNO_TO_PARA_ERROR(EINVAL); + } + obj.data = (char *)mood_name; + obj.size = strlen(mood_name) + 1; ret = osl(osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) { if (errmsg) -- 2.39.5