Commit fa9ab205 by Nathan Lynch Committed by Daniel Lezcano

correct asprintf error checking

asprintf(3) returns -1 (not 0) on error. Signed-off-by: 's avatarNathan Lynch <ntl@pobox.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 5332bb84
...@@ -108,7 +108,10 @@ int main(int argc, char *argv[]) ...@@ -108,7 +108,10 @@ int main(int argc, char *argv[])
if (my_args.rcfile) if (my_args.rcfile)
rcfile = (char *)my_args.rcfile; rcfile = (char *)my_args.rcfile;
else { else {
if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) { int rc;
rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory"); SYSERROR("failed to allocate memory");
return -1; return -1;
} }
......
...@@ -126,7 +126,10 @@ int main(int argc, char *argv[]) ...@@ -126,7 +126,10 @@ int main(int argc, char *argv[])
if (my_args.rcfile) if (my_args.rcfile)
rcfile = (char *)my_args.rcfile; rcfile = (char *)my_args.rcfile;
else { else {
if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) { int rc;
rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory"); SYSERROR("failed to allocate memory");
return -1; return -1;
} }
......
...@@ -117,7 +117,10 @@ int main(int argc, char *argv[]) ...@@ -117,7 +117,10 @@ int main(int argc, char *argv[])
if (my_args.rcfile) if (my_args.rcfile)
rcfile = (char *)my_args.rcfile; rcfile = (char *)my_args.rcfile;
else { else {
if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) { int rc;
rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory"); SYSERROR("failed to allocate memory");
return err; return err;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment