From: Niels Möller Date: Tue, 25 Jun 2013 11:07:02 +0000 (+0200) Subject: nettle-hash.c: Use stack allocation for the small hex output buffer. X-Git-Tag: nettle_3.0_release_20140607~224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d1d5d6de8cc9b66c318d2676b42a87e8f32ec96;p=thirdparty%2Fnettle.git nettle-hash.c: Use stack allocation for the small hex output buffer. --- diff --git a/ChangeLog b/ChangeLog index 6f9fc780..d6327ab7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2013-06-25 Niels Möller + * tools/nettle-hash.c (digest_file): Use stack allocation for the + small hex output buffer. + * examples/io.c (MIN): Deleted unused macro. 2013-05-21 Niels Möller diff --git a/tools/nettle-hash.c b/tools/nettle-hash.c index 5710216e..b4759690 100644 --- a/tools/nettle-hash.c +++ b/tools/nettle-hash.c @@ -108,7 +108,7 @@ digest_file(const struct nettle_hash *alg, else { unsigned i; - char *hex = xalloc(BASE16_ENCODE_LENGTH(8) + 1); + char hex[BASE16_ENCODE_LENGTH(8) + 1]; for (i = 0; i + 8 < digest_length; i += 8) { base16_encode_update(hex, 8, digest + i); @@ -118,7 +118,6 @@ digest_file(const struct nettle_hash *alg, base16_encode_update(hex, digest_length - i, digest + i); hex[BASE16_ENCODE_LENGTH(digest_length - i)] = 0; printf("%s %s\n", hex, alg->name); - free(hex); } free(digest);