aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/mhds_get_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/mhds_get_test.c')
-rw-r--r--src/testcurl/https/mhds_get_test.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/testcurl/https/mhds_get_test.c b/src/testcurl/https/mhds_get_test.c
index 302c6e9a..9b2f9519 100644
--- a/src/testcurl/https/mhds_get_test.c
+++ b/src/testcurl/https/mhds_get_test.c
@@ -147,22 +147,19 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
147 doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX; 147 doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
148 if (NULL == (doc_path = malloc (doc_path_len))) 148 if (NULL == (doc_path = malloc (doc_path_len)))
149 { 149 {
150 fclose (test_fd);
151 fprintf (stderr, MHD_E_MEM); 150 fprintf (stderr, MHD_E_MEM);
152 return -1; 151 return -1;
153 } 152 }
154 if (getcwd (doc_path, doc_path_len) == NULL) 153 if (getcwd (doc_path, doc_path_len) == NULL)
155 { 154 {
156 fclose (test_fd);
157 free (doc_path);
158 fprintf (stderr, "Error: failed to get working directory. %s\n", 155 fprintf (stderr, "Error: failed to get working directory. %s\n",
159 strerror (errno)); 156 strerror (errno));
157 free (doc_path);
160 return -1; 158 return -1;
161 } 159 }
162 160
163 if (NULL == (mem_test_file_local = malloc (len))) 161 if (NULL == (mem_test_file_local = malloc (len)))
164 { 162 {
165 fclose (test_fd);
166 fprintf (stderr, MHD_E_MEM); 163 fprintf (stderr, MHD_E_MEM);
167 return -1; 164 return -1;
168 } 165 }
@@ -170,15 +167,17 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
170 fseek (test_fd, 0, SEEK_SET); 167 fseek (test_fd, 0, SEEK_SET);
171 if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len) 168 if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
172 { 169 {
173 fclose (test_fd); 170 free (mem_test_file_local);
171 free (doc_path);
174 fprintf (stderr, "Error: failed to read test file. %s\n", 172 fprintf (stderr, "Error: failed to read test file. %s\n",
175 strerror (errno)); 173 strerror (errno));
176 return -1; 174 return -1;
177 } 175 }
178 176
179 if (NULL == (cbc.buf = malloc (sizeof (char) * len))) 177 if (NULL == (cbc.buf = malloc (len)))
180 { 178 {
181 fclose (test_fd); 179 free (mem_test_file_local);
180 free (doc_path);
182 fprintf (stderr, MHD_E_MEM); 181 fprintf (stderr, MHD_E_MEM);
183 return -1; 182 return -1;
184 } 183 }
@@ -219,6 +218,9 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
219 fprintf (stderr, "curl_easy_perform failed: `%s'\n", 218 fprintf (stderr, "curl_easy_perform failed: `%s'\n",
220 curl_easy_strerror (errornum)); 219 curl_easy_strerror (errornum));
221 curl_easy_cleanup (c); 220 curl_easy_cleanup (c);
221 free (mem_test_file_local);
222 free (doc_path);
223 free (cbc.buf);
222 return errornum; 224 return errornum;
223 } 225 }
224 226
@@ -229,6 +231,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
229 fprintf (stderr, "Error: local file & received file differ.\n"); 231 fprintf (stderr, "Error: local file & received file differ.\n");
230 free (cbc.buf); 232 free (cbc.buf);
231 free (mem_test_file_local); 233 free (mem_test_file_local);
234 free (doc_path);
232 return -1; 235 return -1;
233 } 236 }
234 237
@@ -281,12 +284,14 @@ setupTestFile ()
281 { 284 {
282 fprintf (stderr, "Error: failed to write `%s. %s'\n", 285 fprintf (stderr, "Error: failed to write `%s. %s'\n",
283 test_file_name, strerror (errno)); 286 test_file_name, strerror (errno));
287 fclose (test_fd);
284 return NULL; 288 return NULL;
285 } 289 }
286 if (fflush (test_fd)) 290 if (fflush (test_fd))
287 { 291 {
288 fprintf (stderr, "Error: failed to flush test file stream. %s\n", 292 fprintf (stderr, "Error: failed to flush test file stream. %s\n",
289 strerror (errno)); 293 strerror (errno));
294 fclose (test_fd);
290 return NULL; 295 return NULL;
291 } 296 }
292 297
@@ -341,6 +346,7 @@ main (int argc, char *const *argv)
341 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 346 if (0 != curl_global_init (CURL_GLOBAL_ALL))
342 { 347 {
343 fprintf (stderr, "Error: %s\n", strerror (errno)); 348 fprintf (stderr, "Error: %s\n", strerror (errno));
349 fclose (test_fd);
344 return -1; 350 return -1;
345 } 351 }
346 352