Fix potential NULL pointer dereferences
This commit is contained in:
parent
55d89321a0
commit
98c521793e
@ -32,6 +32,11 @@ memfile_t *memfile_creat(const char *name, size_t init)
|
||||
mf.offs = 0;
|
||||
|
||||
pmf = (memfile_t *)malloc(sizeof(memfile_t));
|
||||
if (!pmf)
|
||||
{
|
||||
free(mf.base);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(pmf, &mf, sizeof(memfile_t));
|
||||
|
||||
pmf->name = strdup(name);
|
||||
|
@ -44,7 +44,8 @@
|
||||
SC_FUNC char* duplicatestring(const char* sourcestring)
|
||||
{
|
||||
char* result=(char*)malloc(strlen(sourcestring)+1);
|
||||
strcpy(result,sourcestring);
|
||||
if (result!=NULL)
|
||||
strcpy(result,sourcestring);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user