Browse Source

failtest: fix internal cut & paste bug

failtest_malloc should use p->u.malloc not p->u.calloc.  The layouts
are identical, so it doesn't matter, but it's confusing and leaves us
open to weird bugs in future should one change.
Rusty Russell 14 years ago
parent
commit
407057edd6
1 changed files with 3 additions and 3 deletions
  1. 3 3
      ccan/failtest/failtest.c

+ 3 - 3
ccan/failtest/failtest.c

@@ -603,14 +603,14 @@ void *failtest_malloc(size_t size, const char *file, unsigned line)
 
 
 	p = add_history(FAILTEST_MALLOC, file, line, &call);
 	p = add_history(FAILTEST_MALLOC, file, line, &call);
 	if (should_fail(p)) {
 	if (should_fail(p)) {
-		p->u.calloc.ret = NULL;
+		p->u.malloc.ret = NULL;
 		p->error = ENOMEM;
 		p->error = ENOMEM;
 	} else {
 	} else {
-		p->u.calloc.ret = malloc(size);
+		p->u.malloc.ret = malloc(size);
 		set_cleanup(p, cleanup_malloc, struct malloc_call);
 		set_cleanup(p, cleanup_malloc, struct malloc_call);
 	}
 	}
 	errno = p->error;
 	errno = p->error;
-	return p->u.calloc.ret;
+	return p->u.malloc.ret;
 }
 }
 
 
 static void cleanup_realloc(struct realloc_call *call)
 static void cleanup_realloc(struct realloc_call *call)