fixes
authorMaximilian Szengel <gnunet@maxsz.de>
Mon, 9 Apr 2012 14:56:10 +0000 (14:56 +0000)
committerMaximilian Szengel <gnunet@maxsz.de>
Mon, 9 Apr 2012 14:56:10 +0000 (14:56 +0000)
src/regex/regex.c
src/regex/test_regex.c

index 080e5d31e26f3c80f210b017b17ede0c209583d8..250cca47ceb1aeb618571cb2f0dc677b29af544f 100644 (file)
@@ -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;
 
index 4c08c7c53a6254ca638df7fa8212176233349ec6..65c9e6c17c3c81f2b63e0fda45b04b16c9dcd413 100644 (file)
@@ -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<rx_length; i++)