Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] zerrmsg: handle null pointers with %s/%l
- X-seq: zsh-workers 54764
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] zerrmsg: handle null pointers with %s/%l
- Date: Sat, 13 Jun 2026 03:33:03 +0000
- Archived-at: <https://zsh.org/workers/54764>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
same behaviour as printf(3)
a null pointer in an end-user error message is probably a logic error. but this
is useful for lazy debugging
dana
diff --git a/Src/utils.c b/Src/utils.c
index 0b4bb9a82..4de23b6a2 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -313,12 +313,12 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
switch (*fmt++) {
case 's':
str = va_arg(ap, const char *);
- nicezputs(str, file);
+ nicezputs(str ? str : "(null)", file);
break;
case 'l': {
str = va_arg(ap, const char *);
num = va_arg(ap, int);
- fwrite(str, num, 1, file);
+ fwrite(str ? str : "(null)", num, 1, file);
break;
}
case 'L':
Messages sorted by:
Reverse Date,
Date,
Thread,
Author