diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-04-02 07:33:47 +0200 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-04-02 07:33:47 +0200 |
commit | bca76d995713e52327663aecdfa93f5d9ac447a1 (patch) | |
tree | 96a840ce930cedd3d4313471bc296c7c566b2d01 | |
parent | f9d4a134f566b561c9c771166de2139c7ebb8c9d (diff) | |
download | ratpoison-bca76d995713e52327663aecdfa93f5d9ac447a1.zip |
Make sbuf_printf update the len and maxsz internal fields
* sbuf_printf updated the .data field with a freshly allocated string,
but didn't bother setting the .len and .maxsz fields of the sbuf.
Calling other sbuf_* functions on the same sbuf could lead to erratic
behavior and data corruption. eg. in init_screen, the screen's
display_string ended up corrupted, using putenv ratpoison couldn't
override the DISPLAY environment variable in child processes anymore,
introducing a regression on multi-screen setups.
Bug reported and cause tracked down by William Yodlowsky, the maintainer
of the OpenBSD ratpoison port. Thanks!
-rw-r--r-- | src/sbuf.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -123,6 +123,9 @@ sbuf_printf (struct sbuf *b, char *fmt, ...) b->data = xvsprintf (fmt, ap); va_end (ap); + b->len = strlen (b->data); + b->maxsz = b->len + 1; + return b->data; } |