Commit 785a6631 authored by Niels Möller's avatar Niels Möller

(xalloc): New function.

(main): Use xalloc.

Rev: src/nettle/tools/sexp-conv.c:1.15
parent de5c0855
......@@ -44,6 +44,19 @@
#define BUG_ADDRESS "nettle-bugs@lists.lysator.liu.se"
static void *
xalloc(size_t size)
{
void *p = malloc(size);
if (!p)
{
fprintf(stderr, "Virtual memory exhausted.\n");
abort();
}
return p;
}
/* Conversion functions. */
......@@ -328,9 +341,11 @@ main(int argc, char **argv)
options.width, options.prefer_hex);
if (options.hash)
sexp_output_hash_init(&output,
options.hash,
alloca(options.hash->context_size));
{
/* Leaks the context, but that doesn't matter */
void *ctx = xalloc(options.hash->context_size);
sexp_output_hash_init(&output, options.hash, ctx);
}
sexp_get_char(&input);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment