diff --git a/source/compiler/memfile.c b/source/compiler/memfile.c index 4307589..71fa50f 100644 --- a/source/compiler/memfile.c +++ b/source/compiler/memfile.c @@ -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); diff --git a/source/compiler/sclist.c b/source/compiler/sclist.c index 516a276..f15ddd5 100644 --- a/source/compiler/sclist.c +++ b/source/compiler/sclist.c @@ -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; }