diff options
author | Simon Glass <sjg@chromium.org> | 2013-08-16 02:47:57 -0600 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-17 23:17:17 +0000 |
commit | 2500185a83b453580f187087fffc6376f19f8ff0 (patch) | |
tree | 6487b02d14b99d08b272437797b02d500b90b235 /host | |
parent | 1a1138180d237da58b14a594911473e3e53aba26 (diff) | |
download | vboot-2500185a83b453580f187087fffc6376f19f8ff0.tar.gz |
Add memory leak checking
Add checks that the vboot library does not leak memory. This works by
tracking VbExMalloc() calls and making sure that they have an associated
VbExFree().
Adjust host_signature to use VbExFree() instead of free(), so that this
scheme works correctly for existing code.
BUG=chrome-os-partner:21115
BRANCH=pit
TEST=FEATURES=test emerge-peach_pit vboot_reference
Change-Id: I6ccccfbcc162fc43fb75862cd0eddad78ce8b18a
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/66175
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/host_signature.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/host/lib/host_signature.c b/host/lib/host_signature.c index 0ebbca68..1ea6bc40 100644 --- a/host/lib/host_signature.c +++ b/host/lib/host_signature.c @@ -65,7 +65,7 @@ VbSignature* CalculateChecksum(const uint8_t* data, uint64_t size) { sig = SignatureAlloc(SHA512_DIGEST_SIZE, 0); if (!sig) { - free(header_checksum); + VbExFree(header_checksum); return NULL; } sig->sig_offset = sizeof(VbSignature); @@ -74,7 +74,7 @@ VbSignature* CalculateChecksum(const uint8_t* data, uint64_t size) { /* Signature data immediately follows the header */ Memcpy(GetSignatureData(sig), header_checksum, SHA512_DIGEST_SIZE); - free(header_checksum); + VbExFree(header_checksum); return sig; } @@ -128,12 +128,12 @@ VbSignature* CalculateSignature(const uint8_t* data, uint64_t size, /* Prepend the digest info to the digest */ signature_digest = malloc(signature_digest_len); if (!signature_digest) { - free(digest); + VbExFree(digest); return NULL; } Memcpy(signature_digest, digestinfo, digestinfo_size); Memcpy(signature_digest + digestinfo_size, digest, digest_size); - free(digest); + VbExFree(digest); /* Allocate output signature */ sig = SignatureAlloc(siglen_map[key->algorithm], size); |