+/* Licensed under LGPL - see LICENSE file for details */
#include "config.h"
#include <stdarg.h>
#include <string.h>
}
}
+static void free_files(struct saved_file *s)
+{
+ while (s) {
+ struct saved_file *next = s->next;
+ free(s->contents);
+ free(s);
+ s = next;
+ }
+}
+
/* Free up memory, so valgrind doesn't report leaks. */
static void free_everything(void)
{
struct saved_file *files;
/* Are we probing? */
- if (probe_count && --probe_count == 0)
+ if (probe_count && --probe_count == 0 && control_fd != -1)
failtest_cleanup(true, 0);
if (call == &unrecorded_call)
switch (failtest_hook(history, history_num)) {
case FAIL_OK:
break;
+ case FAIL_PROBE:
+ /* Already down probe path? Stop now. */
+ if (!probe_count) {
+ /* FIXME: We should run *parent* and
+ * run probe until calls match up again. */
+ probe_count = 3;
+ break;
+ } else {
+ /* Child should give up now. */
+ if (control_fd != -1)
+ failtest_cleanup(true, 0);
+ /* Parent, don't fail again. */
+ }
case FAIL_DONT_FAIL:
call->fail = false;
return false;
- case FAIL_PROBE:
- /* Already down probe path? Stop now. */
- if (probe_count)
- failtest_cleanup(true, 0);
- /* FIXME: We should run *parent* and run probe until
- * calls match up again. */
- probe_count = 3;
- break;
default:
abort();
}
if (output[1] != STDOUT_FILENO && output[1] != STDERR_FILENO)
close(output[1]);
control_fd = control[1];
+ /* Valgrind spots the leak if we don't free these. */
+ free_files(files);
return true;
}