diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-17 14:32:05 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-17 14:32:05 +0000 |
commit | 0023bacc0565ad444e8facefd1db9b622a8e07d4 (patch) | |
tree | 7ea369f429480af3b4e929839b5b487aa04064de /src/regex/test_regex_eval_api.c | |
parent | 290598582085e0b442caac7a94dcc6e940118e84 (diff) | |
download | gnunet-0023bacc0565ad444e8facefd1db9b622a8e07d4.tar.gz gnunet-0023bacc0565ad444e8facefd1db9b622a8e07d4.zip |
coverity
Diffstat (limited to 'src/regex/test_regex_eval_api.c')
-rw-r--r-- | src/regex/test_regex_eval_api.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index 7538a25d8..35eef6d29 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c | |||
@@ -71,7 +71,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
71 | regmatch_t matchptr[1]; | 71 | regmatch_t matchptr[1]; |
72 | char error[200]; | 72 | char error[200]; |
73 | int result; | 73 | int result; |
74 | char *canonical_regex; | 74 | char *canonical_regex = NULL; |
75 | 75 | ||
76 | /* At least one string is needed for matching */ | 76 | /* At least one string is needed for matching */ |
77 | GNUNET_assert (str_count > 0); | 77 | GNUNET_assert (str_count > 0); |
@@ -96,7 +96,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
96 | if (NULL == dfa) | 96 | if (NULL == dfa) |
97 | { | 97 | { |
98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); | 98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); |
99 | return -1; | 99 | GNUNET_free (matching_str); |
100 | goto error; | ||
100 | } | 101 | } |
101 | 102 | ||
102 | eval = GNUNET_REGEX_eval (dfa, matching_str); | 103 | eval = GNUNET_REGEX_eval (dfa, matching_str); |
@@ -109,7 +110,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
109 | { | 110 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
111 | "Could not compile regex using regcomp: %s\n", rand_rx); | 112 | "Could not compile regex using regcomp: %s\n", rand_rx); |
112 | return -1; | 113 | goto error; |
113 | } | 114 | } |
114 | 115 | ||
115 | eval_check = regexec (&rx, matching_str, 1, matchptr, 0); | 116 | eval_check = regexec (&rx, matching_str, 1, matchptr, 0); |
@@ -127,7 +128,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
127 | if (NULL == dfa) | 128 | if (NULL == dfa) |
128 | { | 129 | { |
129 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); |
130 | return -1; | 131 | goto error; |
131 | } | 132 | } |
132 | 133 | ||
133 | eval_canonical = GNUNET_REGEX_eval (dfa, matching_str); | 134 | eval_canonical = GNUNET_REGEX_eval (dfa, matching_str); |
@@ -138,7 +139,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
139 | "Could not compile regex using regcomp: %s\n", | 140 | "Could not compile regex using regcomp: %s\n", |
140 | canonical_regex); | 141 | canonical_regex); |
141 | return -1; | 142 | goto error; |
142 | } | 143 | } |
143 | 144 | ||
144 | eval_canonical_check = regexec (&rx, matching_str, 1, matchptr, 0); | 145 | eval_canonical_check = regexec (&rx, matching_str, 1, matchptr, 0); |
@@ -169,6 +170,12 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
169 | GNUNET_free (canonical_regex); | 170 | GNUNET_free (canonical_regex); |
170 | 171 | ||
171 | return result; | 172 | return result; |
173 | |||
174 | error: | ||
175 | GNUNET_free_non_null (matching_str); | ||
176 | GNUNET_free_non_null (rand_rx); | ||
177 | GNUNET_free_non_null (canonical_regex); | ||
178 | return -1; | ||
172 | } | 179 | } |
173 | 180 | ||
174 | /** | 181 | /** |