summaryrefslogtreecommitdiff
path: root/src/erasurecode.c
diff options
context:
space:
mode:
authorKota Tsuyuzaki <bloodeagle40234@gmail.com>2015-03-09 11:04:14 +0900
committerKota Tsuyuzaki <bloodeagle40234@gmail.com>2015-03-09 11:04:14 +0900
commitf0fc4f12d6a2dfb14dba09fd4325faae7bdbc9f2 (patch)
treec27232dee6431c667cd21e0bfd6f1c35eb021ff8 /src/erasurecode.c
parentc53f9085b754bafc669e3b674abbd4158369296f (diff)
downloadliberasurecode-f0fc4f12d6a2dfb14dba09fd4325faae7bdbc9f2.tar.gz
Fix memory leak by alloc internal_payload
shss always needs to decode but fragments_to_string will alloc internal_payload as a decoded data. It causes duplicated memory allocation and memory leak.
Diffstat (limited to 'src/erasurecode.c')
-rw-r--r--src/erasurecode.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c
index 65b4456..129ea4b 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -562,18 +562,20 @@ int liberasurecode_decode(int desc,
goto out;
}
- /*
- * Try to re-assebmle the original data before attempting a decode
- */
- ret = fragments_to_string(k, m,
- available_fragments, num_fragments,
- out_data, out_data_len);
-
- /* shss (ntt_backend) must force to decode */
- // TODO: Add a frag and function to handle whether the backend want to decode or not.
- if (ret == 0 && instance->common.id != 5) {
- /* We were able to get the original data without decoding! */
- goto out;
+ if (instance->common.id != 5) {
+ /* shss (ntt_backend) must force to decode */
+ // TODO: Add a frag and function to handle whether the backend want to decode or not.
+ /*
+ * Try to re-assebmle the original data before attempting a decode
+ */
+ ret = fragments_to_string(k, m,
+ available_fragments, num_fragments,
+ out_data, out_data_len);
+
+ if (ret == 0) {
+ /* We were able to get the original data without decoding! */
+ goto out;
+ }
}
/*