diff --git a/limelight-common/RtspConnection.c b/limelight-common/RtspConnection.c index 9dce6d6..2227750 100644 --- a/limelight-common/RtspConnection.c +++ b/limelight-common/RtspConnection.c @@ -1,19 +1,20 @@ #include "Limelight-internal.h" #include "Rtsp.h" +#define RTSP_MAX_RESP_SIZE 16384 + static SOCKET sock = INVALID_SOCKET; static IP_ADDRESS remoteAddr; static int currentSeqNumber = 1; static char rtspTargetUrl[256]; static char sessionIdString[16]; static int hasSessionId = 0; +static char responseBuffer[RTSP_MAX_RESP_SIZE]; /* GFE 2.1.1 */ #define RTSP_CLIENT_VERSION 10 #define RTSP_CLIENT_VERSION_S "10" -#define RTSP_MAX_RESP_SIZE 16384 - /* Create RTSP Option */ static POPTION_ITEM createOptionItem(char* option, char* content) { @@ -81,7 +82,6 @@ static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target) /* Returns 1 on success, 0 otherwise */ static int transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response) { int err, ret = 0; - char responseBuffer[RTSP_MAX_RESP_SIZE]; int offset; PRTSP_MESSAGE responseMsg = NULL; char* serializedMessage = NULL; diff --git a/limelight-common/RtspParser.c b/limelight-common/RtspParser.c index 4335c9d..262be95 100644 --- a/limelight-common/RtspParser.c +++ b/limelight-common/RtspParser.c @@ -28,7 +28,7 @@ static int getMessageLength(PRTSP_MESSAGE msg){ } /* Add length of response-specific strings */ else { - char *statusCodeStr = malloc(sizeof(int)); + char statusCodeStr[16]; sprintf(statusCodeStr, "%d", msg->message.response.statusCode); count += strlen(statusCodeStr); count += strlen(msg->message.response.statusString); @@ -303,9 +303,14 @@ void freeOptionList(POPTION_ITEM optionsHead){ /* Serialize the message struct into a string containing the RTSP message */ char *serializeRtspMessage(PRTSP_MESSAGE msg, int *serializedLength){ int size = getMessageLength(msg); - char *serializedMessage = malloc(size); + char *serializedMessage; POPTION_ITEM current = msg->options; - char *statusCodeStr = malloc(4); // 3 characeters + NUL + char statusCodeStr[16]; + + serializedMessage = malloc(size); + if (serializedMessage == NULL) { + return NULL; + } if (msg->type == TYPE_REQUEST){ /* command [space] */