Fix potential NULL pointer deref, found by Coverity Scan

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-03-04 12:01:24 +01:00
1 parent b71605c819
commit 0be4838e01
1 file changed
+3 -1
+3 -1
View File
@@ -419,8 +419,10 @@ int sh(char *tty)
/* Start /bin/sh as a login shell, i.e. with a prefix '-' */
len = strlen(_PATH_BSHELL) + 2;
arg0 = malloc(len);
if (!arg0)
if (!arg0) {
err(1, "Failed allocating memory");
return 1;
}
snprintf(arg0, len, "-%s", _PATH_BSHELL);
args[0] = arg0;