From fb4020167261837cc0ee9704373c9511d6688add Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 17 Aug 2014 19:08:32 -0700 Subject: [PATCH] Add FLAG_ALLOCATED_PAYLOAD to tell freeMessage() to also free the payload buffer. Don't free the message itself in freeMessage() because it's always stack allocated --- limelight-common/Rtsp.h | 1 + limelight-common/RtspParser.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/limelight-common/Rtsp.h b/limelight-common/Rtsp.h index f9f698c..bc5cd94 100644 --- a/limelight-common/Rtsp.h +++ b/limelight-common/Rtsp.h @@ -16,6 +16,7 @@ #define FLAG_ALLOCATED_OPTION_FIELDS 0x1 #define FLAG_ALLOCATED_MESSAGE_BUFFER 0x2 #define FLAG_ALLOCATED_OPTION_ITEMS 0x4 +#define FLAG_ALLOCATED_PAYLOAD 0x8 /* Linked List to store the options */ typedef struct _OPTION_ITEM { diff --git a/limelight-common/RtspParser.c b/limelight-common/RtspParser.c index ac3d682..9f90946 100644 --- a/limelight-common/RtspParser.c +++ b/limelight-common/RtspParser.c @@ -353,5 +353,9 @@ void freeMessage(PRTSP_MESSAGE msg){ if (msg->flags & FLAG_ALLOCATED_OPTION_ITEMS){ freeOptionList(msg->options); } - free(msg); + + /* If we've allocated the payload */ + if (msg->flags & FLAG_ALLOCATED_PAYLOAD) { + free(msg->payload); + } } \ No newline at end of file