From c6a0fd0acd634c119f7d0f19e44f0d2ee40636cc Mon Sep 17 00:00:00 2001 From: miha-q <> Date: Thu, 21 Mar 2024 12:52:23 -0400 Subject: [PATCH] Thu Mar 21 12:52:23 PM EDT 2024 --- src/openqasm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/openqasm.c b/src/openqasm.c index 0873a83..4fdfcd7 100644 --- a/src/openqasm.c +++ b/src/openqasm.c @@ -778,14 +778,22 @@ int qanselBuildFromSource(char* source, unsigned char** binary, int* binarySize, fprintf(stderr, "QAnsel: Source file truncated.\n"); source[INT_MAX/2] = 0; } - if (!qanselContextValidate(ctx)) return 0; + if (!qanselContextValidate(ctx)) + { + fprintf(stderr, "QAnsel: Invalid context.\n"); + return 0; + } char** chunks; int* chunksAssociatedLines; int chunksCount; int status = qansel_read_script(source, &chunks, &chunksAssociatedLines, &chunksCount); int samplingshots = ctx->sampling_shots; ctx->sampling_shots = 0; - if (!status) return 0; + if (!status) + { + fprintf(stderr, "QAnsel: Read script failure.\n"); + return 0; + } status = qansel_process_chunks(chunks, chunksAssociatedLines, chunksCount, binary, binarySize, ctx, samplingshots); for (int i = 0; i < chunksCount; i++) free(chunks[i]); free(chunks); @@ -794,6 +802,7 @@ int qanselBuildFromSource(char* source, unsigned char** binary, int* binarySize, if (!status) { *binarySize = 0; + fprintf(stderr, "QAnsel: Error encountered while processing chunks.\n"); return 0; } if (ctx->optimization_level & QANSEL_MODE_SMART) -- 2.39.5