[augeas-devel] augeas: master - * src/internal.c (escape, unescape): check allocation failures
David Lutterkort
lutter at fedoraproject.org
Mon Feb 2 05:57:18 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=cd1f54c7f597864eddb897970e49a32f233a3d83
Commit: cd1f54c7f597864eddb897970e49a32f233a3d83
Parent: bb8f2174a80b918620cb841207b94f5a0c2ad7dc
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Sun Feb 1 21:43:07 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Sun Feb 1 21:46:23 2009 -0800
* src/internal.c (escape, unescape): check allocation failures
---
src/internal.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/internal.c b/src/internal.c
index cad9fbd..2e88f9c 100644
--- a/src/internal.c
+++ b/src/internal.c
@@ -163,7 +163,9 @@ char *unescape(const char *s, int len) {
i += 1;
}
- CALLOC(result, size + 1);
+ if (ALLOC_N(result, size + 1) < 0)
+ return NULL;
+
for (i = 0, t = result; i < len; i++, size++) {
if (s[i] == '\\' && (n = strchr(escape_names, s[i+1])) != NULL) {
*t++ = escape_chars[n - escape_names];
@@ -191,7 +193,8 @@ char *escape(const char *text, int cnt) {
else
len += 1;
}
- CALLOC(esc, len+1);
+ if (ALLOC_N(esc, len+1) < 0)
+ return NULL;
e = esc;
for (int i=0; i < cnt; i++) {
char *p;
More information about the augeas-devel
mailing list