Fix memory leak reported by Coverity 91/215691/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 14 Oct 2019 08:33:52 +0000 (10:33 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 14 Oct 2019 08:33:52 +0000 (10:33 +0200)
Change-Id: I2c9642848897fab2994ad612ef41a9703a529d11

src/key.c

index a9fdfefd26768ca41ad06c9dc2591e3a37677e1a..278719ef8b49f1c985eef228781604a7a41a6126 100644 (file)
--- a/src/key.c
+++ b/src/key.c
@@ -960,8 +960,10 @@ static int generate_simple(struct yaca_key_simple_s **out, size_t key_bit_len)
        nk->bit_len = key_bit_len;
 
        ret = yaca_randomize_bytes(nk->d, key_byte_len);
-       if (ret != YACA_ERROR_NONE)
+       if (ret != YACA_ERROR_NONE) {
+               yaca_free(nk);
                return ret;
+       }
 
        *out = nk;
        return YACA_ERROR_NONE;