Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
33f29d6
)
libht: Fixed a bug in trim.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 31 Aug 2010 22:37:29 +0000
(
00:37
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 31 Aug 2010 22:37:29 +0000
(
00:37
+0200)
lib/req.c
patch
|
blob
|
blame
|
history
diff --git
a/lib/req.c
b/lib/req.c
index
4cde483
..
2f975c9
100644
(file)
--- a/
lib/req.c
+++ b/
lib/req.c
@@
-95,9
+95,11
@@
static void trim(struct charbuf *buf)
{
char *p;
- for(p = buf->b; (p - buf->b < buf->d) && isspace(*p); p++);
- memmove(buf->b, p, buf->d -= (p - buf->b));
- for(p = buf->b + buf->d - 1; (p > buf->b) && isspace(*p); p--, buf->d--);
+ if(buf->d > 0) {
+ for(p = buf->b; (p - buf->b < buf->d) && isspace(*p); p++);
+ memmove(buf->b, p, buf->d -= (p - buf->b));
+ for(p = buf->b + buf->d - 1; (p > buf->b) && isspace(*p); p--, buf->d--);
+ }
}
int parseheaders(struct hthead *head, FILE *in)