[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-recutils] [PATCH] src, utils: fail gracefully on allocation errors.
From: |
Giuseppe Scrivano |
Subject: |
[bug-recutils] [PATCH] src, utils: fail gracefully on allocation errors. |
Date: |
Mon, 20 Feb 2012 17:41:50 +0100 |
hello!
this trivial patch fixes some problems reported by memtroll[1]
Thanks for the great work!
Giuseppe
>From 04f6c1ecb7872255c9409bc2e19332178f2169c5 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Mon, 20 Feb 2012 17:40:05 +0100
Subject: [PATCH] src,utils: fail gracefully on allocation errors.
---
ChangeLog | 8 ++++++++
src/rec-parser.c | 2 ++
utils/recsel.c | 1 +
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d552909..a4e3139 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-02-20 Giuseppe Scrivano <address@hidden> (tiny change)
+
+ src,utils: fail gracefully on allocation errors.
+ * src/rec-parser.c (rec_parse_field): Return an error if `new' was
+ not allocated correctly.
+ * utils/recsel.c (main): Fail gracefully if `db' was not allocated
+ correctly.
+
2012-01-19 Jose E. Marchesi <address@hidden>
utils: error reporting must always use recutl_fatal or
diff --git a/src/rec-parser.c b/src/rec-parser.c
index b36a3fd..a9057f9 100644
--- a/src/rec-parser.c
+++ b/src/rec-parser.c
@@ -330,6 +330,8 @@ rec_parse_field (rec_parser_t parser,
{
new = rec_field_new (field_name,
field_value);
+ if (new == NULL)
+ return false;
rec_field_set_source (new, parser->source);
rec_field_set_location (new, location);
diff --git a/utils/recsel.c b/utils/recsel.c
index 7b00bf3..7b7d36f 100644
--- a/utils/recsel.c
+++ b/utils/recsel.c
@@ -577,6 +577,7 @@ main (int argc, char *argv[])
if (!db)
{
res = 1;
+ return res;
}
/* Process the data. */
--
1.7.7.6
1) https://gitorious.org/memtroll
- [bug-recutils] [PATCH] src, utils: fail gracefully on allocation errors.,
Giuseppe Scrivano <=