From f25d19c0fa10451e17d577279d97afe4ba598674 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 14 Feb 2011 23:31:41 -0700 Subject: fix a crash when executing a nonexistent command --- src/uzbl-core.c | 3 ++- tests/test-command.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 0a90bb9..5d62597 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1533,7 +1533,8 @@ parse_cmd_line(const char *ctl_line, GString *result) { if((work_string[0] != '#')) { /* ignore comments */ GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); const CommandInfo *c = parse_command_parts(work_string, a); - run_parsed_command(c, a, result); + if(c) + run_parsed_command(c, a, result); g_array_free (a, TRUE); } } diff --git a/tests/test-command.c b/tests/test-command.c index d07bf79..6d3d81e 100644 --- a/tests/test-command.c +++ b/tests/test-command.c @@ -297,6 +297,12 @@ test_last_result (void) { g_string_free(result, TRUE); } +void +test_no_such_command (void) { + parse_cmd_line("no-such-command", NULL); + /* if we didn't crash then we're ok! */ +} + int main (int argc, char *argv[]) { /* set up tests */ @@ -315,6 +321,8 @@ main (int argc, char *argv[]) { g_test_add_func("/test-command/last-result", test_last_result); + g_test_add_func("/test-command/no-such-command", test_no_such_command); + /* set up uzbl */ initialize(argc, argv); -- cgit v1.2.3