Skip to content

Commit e9a6514

Browse files
committed
Fixes for copilot suggestions
1 parent 3e45820 commit e9a6514

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

blosc/b2nd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,12 @@ int b2nd_concatenate(b2nd_context_t *ctx, const b2nd_array_t *src1, const b2nd_a
13361336
BLOSC_ERROR_NULL(src2, BLOSC2_ERROR_NULL_POINTER);
13371337
BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
13381338

1339+
// Validate the axis parameter
1340+
if (axis < 0 || axis >= src1->ndim) {
1341+
BLOSC_TRACE_ERROR("Axis parameter is out of bounds");
1342+
BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
1343+
}
1344+
13391345
// Keep the src1 shape for later use
13401346
int64_t src1_shape[B2ND_MAX_DIM];
13411347
for (int i = 0; i < src1->ndim; ++i) {

tests/b2nd/test_b2nd_concatenate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ CUTEST_TEST_TEST(concatenate) {
209209
if (backend.persistent) {
210210
b2_storage.urlpath = urlpath;
211211
}
212-
b2_storage2.contiguous = backend.contiguous;
212+
b2_storage.contiguous = backend.contiguous;
213213
b2nd_context_t *ctx = b2nd_create_ctx(&b2_storage, shapes.ndim, shapes.shape1,
214214
shapes.chunkshape1, shapes.blockshape1,
215215
NULL, 0, NULL, 0);
@@ -274,7 +274,7 @@ CUTEST_TEST_TEST(concatenate) {
274274
size_t buffersize2 = elementcount * typesize;
275275
uint8_t *buffer = malloc(buffersize2);
276276

277-
B2ND_TEST_ASSERT(b2nd_get_slice_cbuffer(array, start, stop, buffer, buffershape, buffersize));
277+
B2ND_TEST_ASSERT(b2nd_get_slice_cbuffer(array, start, stop, buffer, buffershape, buffersize2));
278278
// Data in the concatenated array matches the helperbuffer?
279279
uint8_t *buffer_fill = malloc(typesize);
280280
for (int64_t i = 0; i < buffersize / typesize; ++i) {

0 commit comments

Comments
 (0)