Fix code analysis issues and a couple small memory leaks

This commit is contained in:
Cameron Gutman
2014-08-24 12:47:04 -07:00
parent 22f6027cfa
commit 51710ff18a
2 changed files with 11 additions and 6 deletions
+8 -3
View File
@@ -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] */