Mercurial > hg > toybox
comparison lib/lib.c @ 354:3c9f47f4fd33
Fix bug spotted by Jean-Christphe Dubois: reserve space for null terminator.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 16 Apr 2009 17:03:38 -0500 |
parents | a0c3767f0a82 |
children | 5715eed39575 |
comparison
equal
deleted
inserted
replaced
353:287bca550748 | 354:3c9f47f4fd33 |
---|---|
648 char c, *buf = NULL; | 648 char c, *buf = NULL; |
649 long len = 0; | 649 long len = 0; |
650 | 650 |
651 for (;;) { | 651 for (;;) { |
652 if (1>read(fd, &c, 1)) break; | 652 if (1>read(fd, &c, 1)) break; |
653 if (!(len & 63)) buf=xrealloc(buf, len+64); | 653 if (!(len & 63)) buf=xrealloc(buf, len+65); |
654 if ((buf[len++]=c) == end) break; | 654 if ((buf[len++]=c) == end) break; |
655 } | 655 } |
656 if (buf) buf[len]=0; | 656 if (buf) buf[len]=0; |
657 if (plen) *plen = len; | 657 if (plen) *plen = len; |
658 | 658 |