disk/AFsplitter: check argument validity before doing any allocs.

This avoids possible memory leaks.

Found by: Coverity scan.
This commit is contained in:
Vladimir Serbinenko 2015-01-24 21:33:30 +01:00
parent 3b1b39c082
commit 7d97335942

View file

@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
grub_size_t i; grub_size_t i;
grub_uint8_t *bufblock; grub_uint8_t *bufblock;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
return GPG_ERR_INV_ARG;
bufblock = grub_zalloc (blocksize); bufblock = grub_zalloc (blocksize);
if (bufblock == NULL) if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY; return GPG_ERR_OUT_OF_MEMORY;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
return GPG_ERR_INV_ARG;
grub_memset (bufblock, 0, blocksize); grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++) for (i = 0; i < blocknumbers - 1; i++)
{ {