aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-08-03 23:18:21 +0200
committerMattias Andrée <maandree@kth.se>2016-08-03 23:18:21 +0200
commit04dc327c26e2a39d9da30d4dc249a388a948a0ab (patch)
tree020a79679401a68a2bf30a34710c78681ddc0059
parentfix bug (diff)
downloadlibcoopgamma-04dc327c26e2a39d9da30d4dc249a388a948a0ab.tar.gz
libcoopgamma-04dc327c26e2a39d9da30d4dc249a388a948a0ab.tar.bz2
libcoopgamma-04dc327c26e2a39d9da30d4dc249a388a948a0ab.tar.xz
Fix bugs
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/libcoopgamma.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcoopgamma.c b/src/libcoopgamma.c
index 924e936..1beeb8a 100644
--- a/src/libcoopgamma.c
+++ b/src/libcoopgamma.c
@@ -1500,11 +1500,12 @@ int libcoopgamma_synchronise(libcoopgamma_context_t* restrict ctx,
char* value;
if (ctx->inbound_head == ctx->inbound_tail)
- ctx->inbound_head = ctx->inbound_tail = 0;
+ ctx->inbound_head = ctx->inbound_tail = ctx->curline = 0;
if (ctx->inbound_tail > 0)
{
memmove(ctx->inbound, ctx->inbound + ctx->inbound_tail, ctx->inbound_head -= ctx->inbound_tail);
+ ctx->curline -= ctx->inbound_tail;
ctx->inbound_tail = 0;
}
@@ -1538,7 +1539,7 @@ int libcoopgamma_synchronise(libcoopgamma_context_t* restrict ctx,
if (memchr(line, '\0', ctx->inbound_head - ctx->curline) != NULL)
ctx->bad_message = 1;
*p++ = '\0';
- ctx->curline += (size_t)(p - ctx->inbound);
+ ctx->curline = (size_t)(p - ctx->inbound);
if (!*line)
{
ctx->have_all_headers = 1;
@@ -1619,7 +1620,6 @@ int libcoopgamma_synchronise(libcoopgamma_context_t* restrict ctx,
memcpy(msg__ + n__, (payload), (payload_size)); \
if (send_message((ctx), msg__, (size_t)n__ + (payload_size)) < 0) \
goto fail; \
- free(msg__); \
} \
while (0)
@@ -1684,7 +1684,7 @@ static int send_message(libcoopgamma_context_t* restrict ctx, char* msg, size_t
static char* next_header(libcoopgamma_context_t* restrict ctx)
{
char* rc = ctx->inbound + ctx->inbound_tail;
- ctx->inbound_tail += strlen(ctx->inbound) + 1;
+ ctx->inbound_tail += strlen(rc) + 1;
return rc;
}