diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2019-06-29 08:31:23 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2020-07-14 15:52:43 +0200 |
commit | 93f549dd43071d2eb23ded2e625f5160ecd85377 (patch) | |
tree | 7e83bc296e70aeb0433e7a87f4086c682e1f9462 | |
parent | 91c3244c8408f340c546a405996f56a5fb6cf615 (diff) |
Check asprintf() return values correctly. ok and tweaks tb@
-rw-r--r-- | xenodm/dm.c | 8 | ||||
-rw-r--r-- | xenodm/util.c | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/xenodm/dm.c b/xenodm/dm.c index 77920b5..59a0307 100644 --- a/xenodm/dm.c +++ b/xenodm/dm.c @@ -502,7 +502,7 @@ SetWindowPath(struct display *d) unsigned long bytes_after; unsigned char *buf; const char *windowpath; - char *newwindowpath; + char *newwindowpath = NULL; unsigned long num; prop = XInternAtom(d->dpy, "XFree86_VT", False); @@ -549,9 +549,11 @@ SetWindowPath(struct display *d) XFree(buf); windowpath = getenv("WINDOWPATH"); if (!windowpath) { - asprintf(&newwindowpath, "ttyC%lu", num - 1); + if (asprintf(&newwindowpath, "ttyC%lu", num - 1) == -1) + return; } else { - asprintf(&newwindowpath, "%s:%lu", windowpath, num); /* XXX */ + if (asprintf(&newwindowpath, "%s:%lu", windowpath, num) == -1) + return; } free(d->windowPath); d->windowPath = newwindowpath; diff --git a/xenodm/util.c b/xenodm/util.c index 8f6cfe5..5097d44 100644 --- a/xenodm/util.c +++ b/xenodm/util.c @@ -54,12 +54,11 @@ makeEnv (const char *name, const char *value) { char *result; - asprintf(&result, "%s=%s", name, value); - - if (!result) { + if (asprintf(&result, "%s=%s", name, value) == -1) { LogOutOfMem ("makeEnv"); return NULL; } + return result; } |