From cbec7032ee36346649fc5ebecc4b1c01f01178f1 Mon Sep 17 00:00:00 2001 From: Scarlett Date: Thu, 15 Jan 2015 19:38:11 +0900 Subject: Add overflow detection Origin: http://marc.info/?l=openbsd-ports&m=142090828929750&w=2 * main.c: Call exit(1) when out of memory to avoid dereferencing null pointers when gc's malloc fails. * alloc.h: Replacements for w3m's allocation macros which add overflow detection and concentrate the macros in one file. * indep.h, libwc/charset.c, libwc/status.c, matrix.c: Use the overflow-detecting allocation macros from alloc.h. --- matrix.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'matrix.c') diff --git a/matrix.c b/matrix.c index 64fd0ad..bc7a5be 100644 --- a/matrix.c +++ b/matrix.c @@ -34,18 +34,12 @@ #include "config.h" #include "matrix.h" -#include +#include "alloc.h" /* * Macros from "fm.h". */ -#define New(type) ((type*)GC_MALLOC(sizeof(type))) -#define NewAtom(type) ((type*)GC_MALLOC_ATOMIC(sizeof(type))) -#define New_N(type,n) ((type*)GC_MALLOC((n)*sizeof(type))) -#define NewAtom_N(type,n) ((type*)GC_MALLOC_ATOMIC((n)*sizeof(type))) -#define Renew_N(type,ptr,n) ((type*)GC_REALLOC((ptr),(n)*sizeof(type))) - #define SWAPD(a,b) { double tmp = a; a = b; b = tmp; } #define SWAPI(a,b) { int tmp = a; a = b; b = tmp; } -- cgit v1.2.3