diff --git a/ci-meson-build.sh b/ci-meson-build.sh index 0e9ac495..e6333728 100755 --- a/ci-meson-build.sh +++ b/ci-meson-build.sh @@ -39,7 +39,7 @@ tests=( if [[ "$(uname | tr '[:upper:]' '[:lower:]')" == linux* ]]; then echo "--> Running Valgrind check with full features" - meson setup build_valgrind ${tests[0]} -Dtests=true + meson setup build_valgrind ${tests[0]} -Dtests=true -Db_sanitize=address,undefined meson compile -C build_valgrind meson test -C build_valgrind --print-errorlogs --wrap=valgrind || echo "Valgrind issues detected" diff --git a/meson.build b/meson.build index 04ab74d1..3f718192 100644 --- a/meson.build +++ b/meson.build @@ -67,7 +67,8 @@ if is_debug '-Wextra', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', - '-Og' + '-Og', + '-Wpointer-arith' ], language: 'c') if cc.get_id() == 'gcc' add_project_arguments('-fanalyzer', language: 'c') diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index a632ceae..19785399 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1545,6 +1545,10 @@ cmd_ac_remove_form_fields(DataForm* form) char* cmd_ac_complete(ProfWin* window, const char* const input, gboolean previous) { + if (!input) { + return NULL; + } + char* found = NULL; // autocomplete command if ((strncmp(input, "/", 1) == 0) && (!strchr(input, ' '))) { diff --git a/src/tools/editor.c b/src/tools/editor.c index 3c5ee823..70bc13f3 100644 --- a/src/tools/editor.c +++ b/src/tools/editor.c @@ -86,12 +86,18 @@ get_message_from_editor(gchar* message, gchar** returned_message) auto_gchar gchar* editor_with_filename = g_strdup_printf("%s %s", editor, filename); auto_gcharv gchar** editor_argv = g_strsplit(editor_with_filename, " ", 0); + if (!editor_argv || !editor_argv[0]) { + log_error("[Editor] Failed to parse editor command: %s", editor); + return TRUE; + } + // Fork / exec pid_t pid = fork(); if (pid == 0) { - int x = execvp(editor_argv[0], editor_argv); - if (x == -1) { - log_error("[Editor] Failed to exec %s", editor); + if (editor_argv && editor_argv[0]) { + int x = execvp(editor_argv[0], editor_argv); + if (x == -1) + log_error("[Editor] Failed to exec %s", editor); } _exit(EXIT_FAILURE); } else { diff --git a/src/xmpp/form.c b/src/xmpp/form.c index 8f9e0bc9..1b8f84f4 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -477,16 +477,13 @@ form_set_value(DataForm* form, const char* const tag, char* value) while (curr) { FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { - if (g_slist_length(field->values) == 0) { - field->values = g_slist_append(field->values, strdup(value)); - form->modified = TRUE; - return; - } else if (g_slist_length(field->values) == 1) { - free(field->values->data); - field->values->data = strdup(value); - form->modified = TRUE; - return; + if (field->values) { + g_slist_free_full(field->values, free); + field->values = NULL; } + field->values = g_slist_append(NULL, strdup(value)); + form->modified = TRUE; + return; } curr = g_slist_next(curr); }