diff options
author | Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp> | 2016-10-11 19:35:04 -0700 |
---|---|---|
committer | Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp> | 2016-10-11 19:35:04 -0700 |
commit | 10d6fa5f02dd9a3a7bd6cd00ce79b78a1446d7d0 (patch) | |
tree | cf48f923ea4882b1a3f8e67e3964a6ec441ba7b6 /src | |
parent | cb0daba975dfb3b7bffe402d7aa73fac19180f73 (diff) | |
download | liberasurecode-10d6fa5f02dd9a3a7bd6cd00ce79b78a1446d7d0.tar.gz |
Fix reconstruct to return an error when memory allocation failed
As like current code, if we do go jump to just "out" section when
memory allocation failed, liberaurecode/PyECLib will report it as
success. However, in fact, the returned binary is not the one
reconstructed. This patch fixes liberasurecode_reconstruct to return
error code (ENOMEM) if either malloc or memset for working space is
failed.
Change-Id: I7bfc481c7a9bbc64288760df2dc6053c57657b41
Diffstat (limited to 'src')
-rw-r--r-- | src/erasurecode.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c index 31fc884..540cc26 100644 --- a/src/erasurecode.c +++ b/src/erasurecode.c @@ -812,18 +812,21 @@ int liberasurecode_reconstruct_fragment(int desc, data = alloc_zeroed_buffer(sizeof(char*) * k); if (NULL == data) { log_error("Could not allocate data buffer!"); + ret = -ENOMEM; goto out; } parity = alloc_zeroed_buffer(sizeof(char*) * m); if (NULL == parity) { log_error("Could not allocate parity buffer!"); + ret = -ENOMEM; goto out; } missing_idxs = alloc_and_set_buffer(sizeof(int*) * (k + m), -1); if (NULL == missing_idxs) { log_error("Could not allocate missing_idxs buffer!"); + ret = -ENOMEM; goto out; } |