From 08e1b05fdeffaf4e355bc3001348630ac9909eee Mon Sep 17 00:00:00 2001 From: Maximilian Szengel Date: Mon, 9 Apr 2012 14:56:10 +0000 Subject: [PATCH] fixes --- src/regex/regex.c | 13 ++++++++++++- src/regex/test_regex.c | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/regex/regex.c b/src/regex/regex.c index 080e5d31e..250cca47c 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c @@ -589,6 +589,9 @@ dfa_merge_nondistinguishable_states (struct GNUNET_REGEX_Automaton *a) static void dfa_minimize (struct GNUNET_REGEX_Automaton *a) { + if (NULL == a) + return; + GNUNET_assert (DFA == a->type); // 1. remove unreachable states @@ -1100,7 +1103,8 @@ error: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse regex\n"); if (NULL != error_msg) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", error_msg); - GNUNET_free (p); + if (NULL != p) + GNUNET_free (p); while (NULL != ctx.stack_tail) { GNUNET_REGEX_automaton_destroy (ctx.stack_tail); @@ -1163,6 +1167,13 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len) // Create NFA nfa = GNUNET_REGEX_construct_nfa (regex, len); + if (NULL == nfa) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not create DFA, because NFA creation failed\n"); + return NULL; + } + dfa = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Automaton)); dfa->type = DFA; diff --git a/src/regex/test_regex.c b/src/regex/test_regex.c index 4c08c7c53..65c9e6c17 100644 --- a/src/regex/test_regex.c +++ b/src/regex/test_regex.c @@ -75,6 +75,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, unsigned int str_ rand_rxp = rand_rx; matching_strp = matching_str[0]; + current_char = 0; + last_was_op = 1; // Generate random regex and a string that matches the regex for (i=0; i