From: Sage Weil Date: Fri, 16 Nov 2012 22:19:25 +0000 (-0800) Subject: common/ceph_argparse: fix malloc failure check X-Git-Tag: v0.55~81^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8da6ddeaec28f05dc24f06ef7160bbfcf4b66996;p=ceph.git common/ceph_argparse: fix malloc failure check CID 743418 (#1 of 1): Dereference before null check (REVERSE_INULL) Null-checking "argv" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Sage Weil --- diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 421fc3399e2e..646931acdc9e 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -82,7 +82,7 @@ void vec_to_argv(const char *argv0, std::vector& args, int *argc, const char ***argv) { *argv = (const char**)malloc(sizeof(char*) * (args.size() + 1)); - if (!argv) + if (!*argv) throw bad_alloc(); *argc = 1; (*argv)[0] = argv0;