[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/get.c (find_seq): properly report OOM, do not call abort



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=64c27e674388c7dc482e90ac9b7573fe95170049
Commit:        64c27e674388c7dc482e90ac9b7573fe95170049
Parent:        db23496a48941a84b2c72ede0c36700af6da4e55
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Thu Jan 21 17:25:27 2010 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Mon Jan 25 17:22:30 2010 -0800

* src/get.c (find_seq): properly report OOM, do not call abort

---
 src/get.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/get.c b/src/get.c
index 90a8550..c75fc11 100644
--- a/src/get.c
+++ b/src/get.c
@@ -349,12 +349,13 @@ static struct seq *find_seq(const char *name, struct state *state) {
 static struct tree *get_seq(struct lens *lens, struct state *state) {
     assert(lens->tag == L_SEQ);
     struct seq *seq = find_seq(lens->string->str, state);
+    int r;
+
+    r = asprintf((char **) &(state->key), "%d", seq->value);
+    ERR_NOMEM(r < 0, state->info);
 
-    if (asprintf((char **) &(state->key), "%d", seq->value) == -1) {
-        // FIXME: We are out of memory .. find a way to report that
-        abort();
-    }
     seq->value += 1;
+ error:
     return NULL;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]