diff --git a/VerteronDisassemblerEngine/VXInstructionDecoder.c b/VerteronDisassemblerEngine/VXInstructionDecoder.c index d9aa5c1..1296aee 100644 --- a/VerteronDisassemblerEngine/VXInstructionDecoder.c +++ b/VerteronDisassemblerEngine/VXInstructionDecoder.c @@ -526,6 +526,15 @@ VXBaseDataSourceContext* VXMemoryDataSource_Create( if (!thiz || !ctx) { + if (thiz) + { + free(thiz); + } + if (ctx) + { + free(ctx); + } + return NULL; } @@ -614,6 +623,20 @@ VXBaseDataSourceContext* VXCustomDataSource_Create( VXCustomDataSource *thiz = malloc(sizeof(VXCustomDataSource)); VXBaseDataSourceContext *ctx = malloc(sizeof(VXBaseDataSourceContext)); + if (!thiz || !ctx) + { + if (thiz) + { + free(thiz); + } + if (ctx) + { + free(ctx); + } + + return NULL; + } + ctx->d.type = TYPE_CUSTOMDATASOURCE; ctx->d.ptr = thiz; @@ -656,6 +679,15 @@ VXInstructionDecoderContext* VXInstructionDecoder_CreateEx(VXBaseDataSourceConte if (!thiz || !ctx) { + if (thiz) + { + free(thiz); + } + if (ctx) + { + free(ctx); + } + return NULL; } diff --git a/VerteronDisassemblerEngine/VXInstructionFormatter.c b/VerteronDisassemblerEngine/VXInstructionFormatter.c index 84113dd..4613095 100644 --- a/VerteronDisassemblerEngine/VXInstructionFormatter.c +++ b/VerteronDisassemblerEngine/VXInstructionFormatter.c @@ -325,6 +325,15 @@ VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create( if (!thiz || !ctx) { + if (thiz) + { + free(thiz); + } + if (ctx) + { + free(ctx); + } + return NULL; } @@ -807,7 +816,18 @@ VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx( VXBaseInstructionFormatterContext *ctx = malloc(sizeof(VXBaseInstructionFormatterContext)); if (!thiz || !ctx) + { + if (thiz) + { + free(thiz); + } + if (ctx) + { + free(ctx); + } + return NULL; + } ctx->d.type = TYPE_INTELINSTRUCTIONFORMATTER; ctx->d.ptr = thiz;