From 7b613089557d9f8ce17c005f6c887bbc07380f11 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 4 Aug 2010 21:28:17 +0000 Subject: [PATCH] exit(2) on xcalloc failure. From Daniel Dickman , thanks! OK deraadt --- usr.bin/diff/xmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/diff/xmalloc.c b/usr.bin/diff/xmalloc.c index b5340a9fa60..2e80e72e374 100644 --- a/usr.bin/diff/xmalloc.c +++ b/usr.bin/diff/xmalloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.c,v 1.2 2009/06/07 08:39:13 ray Exp $ */ +/* $OpenBSD: xmalloc.c,v 1.3 2010/08/04 21:28:17 ray Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -41,12 +41,12 @@ xcalloc(size_t nmemb, size_t size) void *ptr; if (size == 0 || nmemb == 0) - errx(1, "xcalloc: zero size"); + errx(2, "xcalloc: zero size"); if (SIZE_MAX / nmemb < size) - errx(1, "xcalloc: nmemb * size > SIZE_MAX"); + errx(2, "xcalloc: nmemb * size > SIZE_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) - errx(1, "xcalloc: out of memory (allocating %lu bytes)", + errx(2, "xcalloc: out of memory (allocating %lu bytes)", (u_long)(size * nmemb)); return ptr; } -- 2.20.1