Skip to content

Commit

Permalink
Merge pull request #294 from kalvdans/small-buffers
Browse files Browse the repository at this point in the history
Correct the return code on too small compression buffers
  • Loading branch information
FrancescAlted authored May 10, 2020
2 parents ed7ad70 + a328c4f commit 4f16db5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions blosc/blosc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,7 @@ static int initialize_context_compression(struct blosc_context* context,
return -1;
}
if (destsize < BLOSC_MAX_OVERHEAD) {
fprintf(stderr, "Output buffer size should be larger than %d bytes\n",
BLOSC_MAX_OVERHEAD);
return -1;
return 0;
}

/* Compression level */
Expand Down
6 changes: 3 additions & 3 deletions tests/test_maxout.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ static const char *test_maxout_great_memcpy(void) {
static const char *test_max_overhead(void) {
blosc_init();
cbytes = blosc_compress(0, doshuffle, typesize, size, src, dest, BLOSC_MAX_OVERHEAD - 1);
mu_assert("ERROR: cbytes is not correct", cbytes < 0);
mu_assert("ERROR: cbytes is not correct", cbytes == 0);
blosc_destroy();

blosc_init();
cbytes = blosc_compress(0, doshuffle, typesize, size, src, dest, BLOSC_MAX_OVERHEAD - 2);
mu_assert("ERROR: cbytes is not correct", cbytes < 0);
mu_assert("ERROR: cbytes is not correct", cbytes == 0);
blosc_destroy();

blosc_init();
cbytes = blosc_compress(0, doshuffle, typesize, size, src, dest, 0);
mu_assert("ERROR: cbytes is not correct", cbytes < 0);
mu_assert("ERROR: cbytes is not correct", cbytes == 0);
blosc_destroy();

return 0;
Expand Down

0 comments on commit 4f16db5

Please sign in to comment.