Skip to content

Commit

Permalink
tools/virtiofsd/fuse_opt.c: Replaced a malloc with GLib's g_try_malloc
Browse files Browse the repository at this point in the history
Replaced a malloc() call and its respective free() with
GLib's g_try_malloc() and g_free() calls.

Signed-off-by: Mahmoud Mandour <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  • Loading branch information
i3abghany authored and dagrh committed May 26, 2021
1 parent d14d4f4 commit bf99f30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/virtiofsd/fuse_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ static int process_opt_sep_arg(struct fuse_opt_context *ctx,
}

param = ctx->argv[ctx->argctr];
newarg = malloc(sep + strlen(param) + 1);
newarg = g_try_malloc(sep + strlen(param) + 1);
if (!newarg) {
return alloc_failed();
}

memcpy(newarg, arg, sep);
strcpy(newarg + sep, param);
res = process_opt(ctx, opt, sep, newarg, iso);
free(newarg);
g_free(newarg);

return res;
}
Expand Down

0 comments on commit bf99f30

Please sign in to comment.