nsvi: don't pass NULL string to NSLOG and sprintf v1 APPLIED

Pranjal Kole: 1
 nsvi: don't pass NULL string to NSLOG and sprintf

 1 files changed, 5 insertions(+), 5 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/visurf-devel/patches/28829/mbox | git am -3
Learn more about email & git

[PATCH] nsvi: don't pass NULL string to NSLOG and sprintf Export this patch

musl and glibc's *printf functions convert NULL strings to "(null)"
[0][1], but this is not guaranteed by the spec.

The error message has been changed to "No command given" when argv[0] is
NULL. This matches qutebrowser's behaviour.

[0]: https://git.musl-libc.org/cgit/musl/tree/src/stdio/vfprintf.c#n593
[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf-internal.c;hb=HEAD#l1011
Previous patch didn't get applied (pushed?), might want to look into
that: https://lists.sr.ht/~sircmpwn/visurf-devel/patches/28208
 frontends/visurf/commands.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/frontends/visurf/commands.c b/frontends/visurf/commands.c
index ed4adaeef..22d1cb46e 100644
--- a/frontends/visurf/commands.c
+++ b/frontends/visurf/commands.c
@@ -1327,14 +1327,14 @@ nsvi_command(void *user, const char *cmd)
	if (!command) {
		NSLOG(netsurf, ERROR, "Invalid command '%s'", argv[0]);
		char *error_message;
		if (argv[0] != NULL) {
			error_message = malloc(strlen(argv[0]) + 19);
		if (argv[0] == NULL) {
			error_message = strdup("No command given");
		} else {
			error_message = malloc(25);
			error_message = malloc(strlen(argv[0]) + 19);
			sprintf(error_message, "Invalid command '%s'", argv[0]);
		sprintf(error_message, "Invalid command '%s'", argv[0]);
		NSLOG(netsurf, ERROR, "%s", error_message);
		goto exit;

To git@git.sr.ht:~sircmpwn/visurf
   ed7001c64..3518302d7  master -> master