Skip to content

Commit

Permalink
Fail if open file did not success. Addresses #373.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed May 7, 2022
1 parent 79b6995 commit 4460dfe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions blosc/blosc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,12 +1521,14 @@ static int blosc_d(
BLOSC_ERROR_NULL(chunkpath, BLOSC2_ERROR_MEMORY_ALLOC);
sprintf(chunkpath, "%s/%08X.chunk", frame->urlpath, nchunk);
fp = io_cb->open(chunkpath, "rb", context->schunk->storage->io->params);
BLOSC_ERROR_NULL(fp, BLOSC2_ERROR_FILE_OPEN);
free(chunkpath);
// The offset of the block is src_offset
io_cb->seek(fp, src_offset, SEEK_SET);
}
else {
fp = io_cb->open(urlpath, "rb", context->schunk->storage->io->params);
BLOSC_ERROR_NULL(fp, BLOSC2_ERROR_FILE_OPEN);
// The offset of the block is src_offset
io_cb->seek(fp, chunk_offset + src_offset, SEEK_SET);
}
Expand Down Expand Up @@ -2891,8 +2893,8 @@ int _blosc_getitem(blosc2_context* context, blosc_header* header, const void* sr
context->header_overhead + j * bsize : sw32_(context->bstarts + j);

int32_t cbytes = blosc_d(context->serial_context, bsize, leftoverblock, memcpyed,
src, srcsize, src_offset, j,
tmp2, 0, scontext->tmp, scontext->tmp3);
src, srcsize, src_offset, j,
tmp2, 0, scontext->tmp, scontext->tmp3);
if (cbytes < 0) {
ntbytes = cbytes;
break;
Expand Down

0 comments on commit 4460dfe

Please sign in to comment.