Reset position in buffer each reparse (otherwise, stream will be read corrupt as parser is in wrong state).

This commit is contained in:
Michael Jumper 2011-11-27 23:38:38 -08:00
parent f935075aec
commit 81bea52e4d

View File

@ -360,7 +360,6 @@ int __guac_fill_instructionbuf(guac_socket* socket) {
guac_instruction* guac_protocol_read_instruction(guac_socket* socket, int usec_timeout) { guac_instruction* guac_protocol_read_instruction(guac_socket* socket, int usec_timeout) {
int retval; int retval;
int i = socket->__instructionbuf_parse_start;
/* Loop until a instruction is read */ /* Loop until a instruction is read */
for (;;) { for (;;) {
@ -368,6 +367,9 @@ guac_instruction* guac_protocol_read_instruction(guac_socket* socket, int usec_t
/* Length of element */ /* Length of element */
int element_length = 0; int element_length = 0;
/* Position within buffer */
int i = socket->__instructionbuf_parse_start;
/* Parse instruction in buffer */ /* Parse instruction in buffer */
while (i < socket->__instructionbuf_used_length) { while (i < socket->__instructionbuf_used_length) {