From 265337607e686d667e6404339ed238e7d20abebf Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sat, 30 Apr 2016 19:41:00 +0200 Subject: [PATCH] Fix segfault when no actions are found. --- src/main/findactions.c | 5 +++++ src/main/main.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/main/findactions.c b/src/main/findactions.c index 5e58201..e8fb5aa 100644 --- a/src/main/findactions.c +++ b/src/main/findactions.c @@ -24,6 +24,7 @@ #include #include #include +#include typedef struct ActionListStruct { char** list; @@ -39,10 +40,14 @@ static int strcmp_wrapper ( const void* parA, const void* parB ); void find_actions (char*** parOut, size_t* parCount) { ActionList list; + assert(parOut); + assert(parCount); + list.count = 0; foreach_dir(&increase_actionlist, &list); if (0 == list.count) { *parOut = NULL; + *parCount = 0; return; } diff --git a/src/main/main.c b/src/main/main.c index a404e24..deeb75e 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -29,6 +29,7 @@ #include #include #include +#include /* This program can be run either with the name of a subcommand as its first * parameter (eg: dindexer locate), plus some optional parameters that are just @@ -87,6 +88,7 @@ int main (int parArgc, char* parArgv[]) { specified_action = parArgv[1]; else specified_action = ""; + assert((actions and actions_count) or (not actions and not actions_count)); selected_action = foreach_avail_action(&same_action, actions, actions_count, specified_action); if (actions_count == selected_action) {