From 04dc327c26e2a39d9da30d4dc249a388a948a0ab Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 3 Aug 2016 23:18:21 +0200 Subject: Fix bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libcoopgamma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2