diff options
author | rsc <devnull@localhost> | 2006-02-21 20:46:49 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-02-21 20:46:49 +0000 |
commit | 95409400f71c426d4ef5811f5dbdf1c0778464f5 (patch) | |
tree | 4443f8ea9f57b6fe0f33949d0dba65d4f9ce340f /src | |
parent | c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4 (diff) | |
download | plan9port-95409400f71c426d4ef5811f5dbdf1c0778464f5.tar.gz plan9port-95409400f71c426d4ef5811f5dbdf1c0778464f5.tar.bz2 plan9port-95409400f71c426d4ef5811f5dbdf1c0778464f5.zip |
events buffer need not end in NUL
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/acme/mail/mesg.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/wind.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/xfid.c | 11 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/cmd/acme/mail/mesg.c b/src/cmd/acme/mail/mesg.c index 9406b799..2beedb05 100644 --- a/src/cmd/acme/mail/mesg.c +++ b/src/cmd/acme/mail/mesg.c @@ -346,7 +346,7 @@ readfile(char *dir, char *name, int *np) len = d->length; free(d); data = emalloc(len+1); - fsread(fid, data, len); + len = fsreadn(fid, data, len); fsclose(fid); if(np != nil) *np = len; diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index a2106ed2..2f0328c8 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -679,7 +679,7 @@ winevent(Window *w, char *fmt, ...) if(b == nil) error("vsmprint failed"); n = strlen(b); - w->events = realloc(w->events, w->nevents+1+n); + w->events = erealloc(w->events, w->nevents+1+n); w->events[w->nevents++] = w->owner; memmove(w->events+w->nevents, b, n); free(b); diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 126a5fe9..15b411ce 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -976,7 +976,6 @@ void xfideventread(Xfid *x, Window *w) { Fcall fc; - char *b; int i, n; i = 0; @@ -1000,10 +999,14 @@ xfideventread(Xfid *x, Window *w) fc.count = n; fc.data = w->events; respond(x, &fc, nil); - b = w->events; - w->events = estrdup(w->events+n); - free(b); w->nevents -= n; + if(w->nevents){ + memmove(w->events, w->events+n, w->nevents); + w->events = erealloc(w->events, w->nevents); + }else{ + free(w->events); + w->events = nil; + } } void |