diff --git a/Bindings/C/VXInstructionDecoderC.c b/Bindings/C/VXInstructionDecoderC.c index 8541cc2..7c6d862 100644 --- a/Bindings/C/VXInstructionDecoderC.c +++ b/Bindings/C/VXInstructionDecoderC.c @@ -287,6 +287,11 @@ VXBaseDataSourceContext* VXMemoryDataSource_Create( VXMemoryDataSource *thiz = malloc(sizeof(VXMemoryDataSource)); VXBaseDataSourceContext *ctx = malloc(sizeof(VXBaseDataSourceContext)); + if (!thiz || !ctx) + { + return NULL; + } + ctx->d.type = TYPE_MEMORYDATASOURCE; ctx->d.ptr = thiz; @@ -362,6 +367,11 @@ VXInstructionDecoderContext* VXInstructionDecoder_CreateEx( VXInstructionDecoder *thiz = malloc(sizeof(VXInstructionDecoder)); VXInstructionDecoderContext *ctx = malloc(sizeof(VXInstructionDecoderContext)); + if (!thiz || !ctx) + { + return NULL; + } + ctx->d.ptr = thiz; ctx->d.type = TYPE_INSTRUCTIONDECODER; @@ -1590,7 +1600,7 @@ static bool VXInstructionDecoder_DecodeOpcode(VXInstructionDecoderContext *ctx, { if (info->operand[i].type != OPTYPE_NONE) { - info->operand[i - 1].access_mode = OPACCESSMODE_READ; + info->operand[i].access_mode = OPACCESSMODE_READ; } } if (info->operand[0].type != OPTYPE_NONE) diff --git a/Bindings/C/VXInstructionFormatterC.c b/Bindings/C/VXInstructionFormatterC.c index 64db11f..cd81a15 100644 --- a/Bindings/C/VXInstructionFormatterC.c +++ b/Bindings/C/VXInstructionFormatterC.c @@ -193,6 +193,11 @@ VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create( VXCustomSymbolResolver *thiz = malloc(sizeof(VXCustomSymbolResolver)); VXBaseSymbolResolverContext *ctx = malloc(sizeof(VXBaseSymbolResolverContext)); + if (!thiz || !ctx) + { + return NULL; + } + ctx->d.type = TYPE_CUSTOMSYMBOLRESOLVER; ctx->d.ptr = thiz; @@ -676,6 +681,9 @@ VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx( VXIntelInstructionFormatter *thiz = malloc(sizeof(VXIntelInstructionFormatter)); VXBaseInstructionFormatterContext *ctx = malloc(sizeof(VXBaseInstructionFormatterContext)); + if (!thiz || !ctx) + return NULL; + ctx->d.type = TYPE_INTELINSTRUCTIONFORMATTER; ctx->d.ptr = thiz; diff --git a/Examples/CBindings/test.c b/Examples/CBindings/test.c index 3cfa534..ae68857 100644 --- a/Examples/CBindings/test.c +++ b/Examples/CBindings/test.c @@ -113,6 +113,11 @@ int main() } } + VXBaseDataSource_Release(input32); + VXBaseDataSource_Release(input64); + VXBaseInstructionFormatter_Release(formatter); + VXInstructionDecoder_Release(decoder); + getchar(); return 0; } \ No newline at end of file