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.
This commit is contained in:
Scarlett authored and Tatsuya Kinoshita committed 2015-01-15 19:38:11 +09:00
1 parent fde71b37d2
commit cbec7032ee
6 files changed
+51 -17

No files matched your search

+1 -2
View File
@@ -1,8 +1,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <gc.h>
#define New_N(type,n) ((type*)GC_MALLOC((n)*sizeof(type)))
#include "../alloc.h"
#include "wc.h"
+1 -2
View File
@@ -1,7 +1,6 @@
#include <string.h>
#include <gc.h>
#define New_N(type,n) ((type*)GC_MALLOC((n)*sizeof(type)))
#include "../alloc.h"
#include "wc.h"
#ifdef USE_UNICODE