Fixed memory leak in guac_instruction_free()

This commit is contained in:
Michael Jumper 2011-12-21 01:35:16 -08:00
parent a1b93e0802
commit 05b0a09a8a

View File

@ -554,13 +554,23 @@ guac_instruction* guac_protocol_expect_instruction(guac_socket* socket, int usec
void guac_instruction_free(guac_instruction* instruction) { void guac_instruction_free(guac_instruction* instruction) {
int argc = instruction->argc;
/* Free opcode */ /* Free opcode */
free(instruction->opcode); free(instruction->opcode);
/* Free argv if set (may be NULL of argc is 0) */ /* 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->argv);
}
/* Free instruction */ /* Free instruction */
free(instruction); free(instruction);