In the same vein as yesterday's diff for 'locate', I (well, Clang static
analyzer and me) found in bin/systrace/alias.c that the variable
'reverse' is defined as a pointer to struct systrace_revalias but is
initialized as follows
reverse = calloc(1, sizeof(struct systrace_alias));
On amd64 :
sizeof(struct systrace_alias) == 288
sizeof(struct systrace_revalias) == 112
I did not find in the code any reason to allocate sizeof(struct
systrace_alias) instead of sizeof(struct systrace_revalias).
The diff below changes sizeof(struct systrace_alias) to
sizeof(*reverse). For the sake of consistency I also modified the malloc
call on line 145. Regress tests run fine.
Nicolas Bedos
Index: src/bin/systrace/alias.c
===================================================================
RCS file: /cvs/src/bin/systrace/alias.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 alias.c
--- src/bin/systrace/alias.c 4 Dec 2012 02:24:47 -0000 1.6
+++ src/bin/systrace/alias.c 16 Nov 2014 11:38:58 -0000
@@ -122,7 +122,7 @@ systrace_reverse(const char *emulation,
if (reverse != NULL)
return (reverse);
- reverse = calloc(1, sizeof(struct systrace_alias));
+ reverse = calloc(1, sizeof(*reverse));
if (reverse == NULL)
err(1, "%s: %s-%s: malloc", __func__, emulation, name);
@@ -145,7 +145,7 @@ systrace_new_alias(const char *emulation
struct systrace_alias *alias;
struct systrace_revalias *reverse;
- alias = malloc(sizeof(struct systrace_alias));
+ alias = malloc(sizeof(*alias));
if (alias == NULL)
err(1, "%s: %s-%s: malloc", __func__, emulation, name);