From 81bea52e4db9b2eafac1bf10cd0c099a72187922 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Nov 2011 23:38:38 -0800 Subject: [PATCH] Reset position in buffer each reparse (otherwise, stream will be read corrupt as parser is in wrong state). --- libguac/src/protocol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 0ff61bbc..71cc0a9f 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -360,14 +360,16 @@ int __guac_fill_instructionbuf(guac_socket* socket) { guac_instruction* guac_protocol_read_instruction(guac_socket* socket, int usec_timeout) { int retval; - int i = socket->__instructionbuf_parse_start; - + /* Loop until a instruction is read */ for (;;) { /* Length of element */ int element_length = 0; + /* Position within buffer */ + int i = socket->__instructionbuf_parse_start; + /* Parse instruction in buffer */ while (i < socket->__instructionbuf_used_length) {