ref: c92eb2ffeaf2011ec73c7ad66b317484f80eb446
parent: 26ae1e1f2fa5459a40de59f7934755da8eb31ec6
author: mkf <mkf@cloud9p.org>
date: Thu Jun 6 15:00:02 EDT 2024
vfprint: work around nasty free() bug in OpenBSD somehow, this only happens in OpenBSD 7.5, i'm very sure why. i can't reproduce it on 7.4, nor my friends have reported it in Linux or Windows. i guess you get what you deserve. someone have got to pay the price for paranoia.
--- a/unix.c
+++ b/unix.c
@@ -74,13 +74,12 @@
int
vfprint(int fd, char *fmt, va_list arg)
{
- char *s = (char*)emalloc(128);
+ char s[512];
int n;
n = vsprint(s, fmt, arg);
if(write(fd, s, n) < n)
perror("couldn't write");
- free(s);
return n;
}