diff options
author | Ethan Vrhel <ethanvrhel@gmail.com> | 2022-06-27 13:38:23 -0700 |
---|---|---|
committer | Ethan Vrhel <ethanvrhel@gmail.com> | 2022-06-27 14:56:22 -0700 |
commit | 532279f73778f3b33ed126a27b0e542581162be9 (patch) | |
tree | 3ef8f2787806088208b00eddd8d375b9a542a048 /xps | |
parent | 4dfa63fbb6d3049b9f462054aa786ca4b182d50a (diff) | |
download | ghostpdl-532279f73778f3b33ed126a27b0e542581162be9.tar.gz |
Coverity 379207 fixed - control flow issues
Removed unnecessary control statement, and added new one for error
checking.
Diffstat (limited to 'xps')
-rw-r--r-- | xps/xpszip.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/xps/xpszip.c b/xps/xpszip.c index e07e516c1..14ac76751 100644 --- a/xps/xpszip.c +++ b/xps/xpszip.c @@ -495,25 +495,28 @@ xps_read_dir_part(xps_context_t *ctx, const char *name) } /* Inflate the pieces */ - if (count) + + part = xps_new_part(ctx, name, size); + if (!part) { - part = xps_new_part(ctx, name, size); - offset = 0; - for (i = 0; i < count; i++) - { - if (i < count - 1) - gs_snprintf(buf, sizeof(buf), "%s%s/[%d].piece", ctx->directory, name, i); - else - gs_snprintf(buf, sizeof(buf), "%s%s/[%d].last.piece", ctx->directory, name, i); - file = gp_fopen(ctx->memory, buf, "rb"); - n = xps_fread(part->data + offset, 1, size - offset, file); - offset += n; - gp_fclose(file); - } - return part; + gs_rethrow1(-1, "failed to create part '%s'", name); + return NULL; } - return NULL; + offset = 0; + for (i = 0; i < count; i++) + { + if (i < count - 1) + gs_snprintf(buf, sizeof(buf), "%s%s/[%d].piece", ctx->directory, name, i); + else + gs_snprintf(buf, sizeof(buf), "%s%s/[%d].last.piece", ctx->directory, name, i); + file = gp_fopen(ctx->memory, buf, "rb"); + n = xps_fread(part->data + offset, 1, size - offset, file); + offset += n; + gp_fclose(file); + } + return part; + } xps_part_t * |