[PATCH] nsvi: don't segfault on empty command
Export this patch
nsvi was segfaulting when an empty command was entered in exline, caused
by calling strlen on a null pointer.
---
frontends/visurf/commands.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/frontends/visurf/commands.c b/frontends/visurf/commands.c
index 9600bde73..b244511d6 100644
--- a/frontends/visurf/commands.c
+++ b/frontends/visurf/commands.c
@@ -1326,7 +1326,12 @@ nsvi_command(void *user, const char *cmd)
cmd_compar);
if (!command) {
NSLOG(netsurf, ERROR, "Invalid command '%s'", argv[0]);
- char *error_message = malloc(strlen(argv[0]) + 19);
+ char *error_message;
+ if (argv[0] != NULL) {
+ error_message = malloc(strlen(argv[0]) + 19);
+ } else {
+ error_message = malloc(25);
+ }
sprintf(error_message, "Invalid command '%s'", argv[0]);
handle_error(error_message);
goto exit;
--
2.34.1
Thanks!
To git@git.sr.ht:~sircmpwn/visurf
940de57e2..6be410ec3 master -> master