Commit 98e03f49 authored by Judit Foglszinger's avatar Judit Foglszinger

Adding patch to fix memory allocation error

Thanks to Dmitry Borisyuk <q1werty@i.com.ua> for the patch.
parent b65d8b2f
Description: Catch ENOMEM in {m,re}alloc_array (prevent segfaults).
Author: Dmitry Borisyuk <q1werty@i.com.ua>
--- a/Area.C
+++ b/Area.C
@@ -30,7 +30,7 @@
/***************************************************************************/
-
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
@@ -45,10 +45,14 @@
/* ------------------------------------------------------------------------- */
+static void* alloc_error() {
+ perror("html2text: error"); abort();
+}
+
#define malloc_array(type, size)\
-((type *) malloc(sizeof(type) * (size)))
+((type *) (malloc(sizeof(type) * (size)) ? : alloc_error()))
#define realloc_array(array, type, size) \
-((array) = (type *) realloc((array), sizeof(type) * (size)))
+((array) = (type *) (realloc((array), sizeof(type) * (size)) ? : alloc_error()))
#define copy_array(from, to, type, count) \
((void) memcpy((to), (from), (count) * sizeof(type)))
......@@ -14,3 +14,4 @@
950-validate-width-parameter.patch
960-fix-utf8-mode-quadratic-runtime.patch
970-fix-arg-parsing.patch
980-catch-alloc-err.patch
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