Menu

#18 Dereferencing a possible NULL Pointer without NULL check in mmc.c

v1.0 (example)
open
nobody
None
5
2015-11-07
2015-11-07
No

Version : libmms-0.6.4
file : mms.c
line no : 731
NULL check is missing on pointer before dereferencing it.
In file mms.c, calloc is being used for memory allocation and retured pointer is assigned to variable ‘this’.
Variable 'this' is dereferenced in file mms.c at line no 731, with null check.

Current code :

this = (mms_t*)calloc(1, sizeof(mms_t));

this->url = strdup (url);
this->s = -1;

Suggested code :

this = (mms_t*)calloc(1, sizeof(mms_t));
if (!this) {
lprintf("error, calloc failed\n");
return NULL;
}

this->url = strdup (url);
this->s = -1;

Please check the attached patch.

1 Attachments

Discussion


Log in to post a comment.