summaryrefslogtreecommitdiff
path: root/src/erasurecode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/erasurecode.c')
-rw-r--r--src/erasurecode.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c
index 57054b9..7d8ef7d 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -253,6 +253,12 @@ int liberasurecode_instance_create(const ec_backend_id_t id,
if (id >= EC_BACKENDS_MAX)
return -EBACKENDNOTSUPP;
+ if ((args->k + args->m) > MAX_FRAGMENTS_NUM){
+ log_error("Fragments sum (k + m) must be less than %d\n",
+ MAX_FRAGMENTS_NUM);
+ return -EINVALIDPARAMS;
+ }
+
/* Allocate memory for ec_backend instance */
instance = calloc(1, sizeof(*instance));
if (NULL == instance)
@@ -683,13 +689,13 @@ out:
/* Free the buffers allocated in prepare_fragments_for_decode */
if (realloc_bm != 0) {
for (i = 0; i < k; i++) {
- if (realloc_bm & (1 << i)) {
+ if (realloc_bm & (BASE_64BIT << i)) {
free(data[i]);
}
}
for (i = 0; i < m; i++) {
- if (realloc_bm & (1 << (i + k))) {
+ if (realloc_bm & (BASE_64BIT << (i + k))) {
free(parity[i]);
}
}
@@ -873,13 +879,13 @@ out:
/* Free the buffers allocated in prepare_fragments_for_decode */
if (realloc_bm != 0) {
for (i = 0; i < k; i++) {
- if (realloc_bm & (1 << i)) {
+ if (realloc_bm & (BASE_64BIT << i)) {
free(data[i]);
}
}
for (i = 0; i < m; i++) {
- if (realloc_bm & (1 << (i + k))) {
+ if (realloc_bm & (BASE_64BIT << (i + k))) {
free(parity[i]);
}
}