diff options
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/base_context.c | 2 | ||||
-rw-r--r-- | fitz/base_error.c | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c index 231d9104..c65377a8 100644 --- a/fitz/base_context.c +++ b/fitz/base_context.c @@ -93,7 +93,7 @@ new_context_phase1(fz_alloc_context *alloc, fz_locks_context *locks) if (!ctx->error) goto cleanup; ctx->error->top = -1; - ctx->error->errcode = 0; + ctx->error->errcode = FZ_ERROR_NONE; ctx->error->message[0] = 0; ctx->warn = fz_malloc_no_throw(ctx, sizeof(fz_warn_context)); diff --git a/fitz/base_error.c b/fitz/base_error.c index f16dd4d0..50b3c5aa 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -89,7 +89,6 @@ int fz_push_try(fz_error_context *ex) { assert(ex); ex->top++; - ex->errcode = FZ_ERROR_NONE; /* Normal case, get out of here quick */ if (ex->top < nelem(ex->stack)-1) return 1; /* We exit here, and the setjmp sets the code to 0 */ @@ -107,15 +106,13 @@ int fz_push_try(fz_error_context *ex) int fz_caught(fz_context *ctx) { - assert(ctx); - assert(ctx->error); + assert(ctx && ctx->error && ctx->error->errcode >= FZ_ERROR_NONE); return ctx->error->errcode; } const char *fz_caught_message(fz_context *ctx) { - assert(ctx); - assert(ctx->error); + assert(ctx && ctx->error && ctx->error->errcode >= FZ_ERROR_NONE); return ctx->error->message; } @@ -136,12 +133,16 @@ void fz_throw(fz_context *ctx, int code, const char *fmt, ...) void fz_rethrow(fz_context *ctx) { + assert(ctx && ctx->error && ctx->error->errcode >= FZ_ERROR_NONE); throw(ctx->error); } void fz_rethrow_message(fz_context *ctx, const char *fmt, ...) { va_list args; + + assert(ctx && ctx->error && ctx->error->errcode >= FZ_ERROR_NONE); + va_start(args, fmt); vsnprintf(ctx->error->message, sizeof ctx->error->message, fmt, args); va_end(args); |