From: Jason Wessel Date: Thu, 3 Mar 2011 02:21:07 +0000 (-0500) Subject: ustctl: Fix memory allocation problem with compatibility args X-Git-Tag: v1.9.1~438 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=68d96813ccbb41602f92b45e8a5f61dea7525c35;p=lttng-ust.git ustctl: Fix memory allocation problem with compatibility args The parenthesis were missing to make the malloc math have the correct precedence. The addition needs to occur before the multiplication. The result is the same but for clarity also change change char ** to char * because we are allocating an array of char pointers. Signed-off-by: Jason Wessel Signed-off-by: Mathieu Desnoyers --- diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c index d642178a..807af8ca 100644 --- a/ustctl/ustctl.c +++ b/ustctl/ustctl.c @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) case DESTROY_TRACE: case ENABLE_MARKER: case DISABLE_MARKER: - args = (char **)malloc(sizeof(char **) * argc + 3); + args = (char **)malloc(sizeof(char *) * (argc + 3)); optind--; args[optind] = strdup(&argv[optind][2]); for (i = optind + 1; i < argc; i++) {