From 05b0a09a8ab776f0d3e624ce3c5048b092f5a40e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 21 Dec 2011 01:35:16 -0800 Subject: [PATCH] Fixed memory leak in guac_instruction_free() --- libguac/src/protocol.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 71cc0a9f..89fe785a 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -554,13 +554,23 @@ guac_instruction* guac_protocol_expect_instruction(guac_socket* socket, int usec void guac_instruction_free(guac_instruction* instruction) { + int argc = instruction->argc; + /* Free opcode */ free(instruction->opcode); /* Free argv if set (may be NULL of argc is 0) */ - if (instruction->argv) + if (instruction->argv) { + + /* All argument values */ + while (argc > 0) + free(instruction->argv[--argc]); + + /* Free actual array */ free(instruction->argv); + } + /* Free instruction */ free(instruction);