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. --- indep.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'indep.h') diff --git a/indep.h b/indep.h index 84416ed..2809832 100644 --- a/indep.h +++ b/indep.h @@ -1,7 +1,7 @@ /* $Id: indep.h,v 1.16 2003/09/22 21:02:19 ukai Exp $ */ #ifndef INDEP_H #define INDEP_H -#include +#include "alloc.h" #include "Str.h" #include "config.h" @@ -92,11 +92,6 @@ extern char *w3m_etc_dir(); extern char *w3m_conf_dir(); extern char *w3m_help_dir(); -#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 New_Reuse(type,ptr,n) ((type*)GC_REALLOC((ptr),(n)*sizeof(type))) #define NewWithoutGC(type) ((type*)xmalloc(sizeof(type))) #define NewWithoutGC_N(type,n) ((type*)xmalloc((n)*sizeof(type))) #define NewWithoutGC_Reuse(type,ptr,n) ((type*)xrealloc(ptr,(n)*sizeof(type))) -- cgit v1.2.3