From 09614bba4182c6d8b3eb4a914dfc3c16135ee76d Mon Sep 17 00:00:00 2001 From: Jacob Adams Date: Wed, 18 Mar 2015 09:04:01 -0400 Subject: [PATCH 1/3] memset the real size of res --- minix/commands/swifi/systest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minix/commands/swifi/systest.c b/minix/commands/swifi/systest.c index 66277c748..f75f49f48 100644 --- a/minix/commands/swifi/systest.c +++ b/minix/commands/swifi/systest.c @@ -73,7 +73,7 @@ main(int argc, char * argv[]) goto Cleanup; } - memset(res, 0, sizeof(res)); + memset(res, 0, sizeof(*res)); /* // Find out where the faults will be injected From 75a7082c90086c55e5aaf596b940cf17c59bd990 Mon Sep 17 00:00:00 2001 From: Jacob Adams Date: Wed, 18 Mar 2015 09:11:18 -0400 Subject: [PATCH 2/3] Use the real size of res --- minix/commands/swifi/systest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/minix/commands/swifi/systest.c b/minix/commands/swifi/systest.c index f75f49f48..f45967228 100644 --- a/minix/commands/swifi/systest.c +++ b/minix/commands/swifi/systest.c @@ -66,14 +66,14 @@ main(int argc, char * argv[]) goto Usage; } } - - res = malloc(arg * sizeof(swifi_result_t)); + size_t ressize = arg * sizeof(swifi_result_t); + res = malloc(ressize); if (res == NULL) { printf("Out of memory\n"); goto Cleanup; } - memset(res, 0, sizeof(*res)); + memset(res, 0, sizeof(ressize)); /* // Find out where the faults will be injected From c8150407a11fc7cbc7c5db47b87a76d5bd6174bc Mon Sep 17 00:00:00 2001 From: Jacob Adams Date: Wed, 18 Mar 2015 09:25:16 -0400 Subject: [PATCH 3/3] No need to sizeof a size_t --- minix/commands/swifi/systest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minix/commands/swifi/systest.c b/minix/commands/swifi/systest.c index f45967228..e0a7234dd 100644 --- a/minix/commands/swifi/systest.c +++ b/minix/commands/swifi/systest.c @@ -73,7 +73,7 @@ main(int argc, char * argv[]) goto Cleanup; } - memset(res, 0, sizeof(ressize)); + memset(res, 0, ressize); /* // Find out where the faults will be injected