summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/spec.y
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-03-24 14:01:36 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-03-31 09:43:29 -0700
commit41f05fcefc1c192a3f322e827114897ec0ace316 (patch)
treec5500aed5d5f993256a98341b2482fdefaf3c3c1 /libglusterfs/src/spec.y
parentaa6028a600ccfea14d3f047402dfe157047cabdc (diff)
Fix further cppcheck reported issues.
Reported-by: Patrick Matthäi <pmatthaei@debian.org> Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 420 (fix leaks pointed out by cppcheck static analyzer) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=420
Diffstat (limited to 'libglusterfs/src/spec.y')
-rw-r--r--libglusterfs/src/spec.y21
1 files changed, 20 insertions, 1 deletions
diff --git a/libglusterfs/src/spec.y b/libglusterfs/src/spec.y
index ec9101a2..84ab4df8 100644
--- a/libglusterfs/src/spec.y
+++ b/libglusterfs/src/spec.y
@@ -152,11 +152,18 @@ new_section (char *name)
{
extern int yylineno;
xlator_t *trav = complete_tree;
- xlator_t *node = (void *) calloc (1, sizeof (*node));
+ xlator_t *node = NULL;
+
+ node = (void *) calloc (1, sizeof (*node));
+ if (!node) {
+ gf_log ("parser", GF_LOG_ERROR, "Out of memory");
+ return -1;
+ }
if (!name) {
gf_log ("parser", GF_LOG_DEBUG,
"Invalid argument name: '%s'", name);
+ FREE (node);
return -1;
}
@@ -283,6 +290,10 @@ section_sub (char *sub)
}
xlparent = (void *) calloc (1, sizeof (*xlparent));
+ if (!xlparent) {
+ gf_log ("parser", GF_LOG_ERROR, "Out of memory");
+ return -1;
+ }
xlparent->xlator = tree;
tmp = trav->parents;
@@ -295,6 +306,11 @@ section_sub (char *sub)
}
xlchild = (void *) calloc (1, sizeof(*xlchild));
+ if (!xlchild) {
+ FREE (xlparent);
+ gf_log ("parser", GF_LOG_ERROR, "Out of memory");
+ return -1;
+ }
xlchild->xlator = trav;
tmp = tree->children;
@@ -476,11 +492,14 @@ parse_backtick (FILE *srcfp, FILE *dstfp)
cmd = CALLOC (cmd_buf_size, 1);
if (cmd == NULL) {
+ gf_log ("parser", GF_LOG_ERROR, "Out of memory");
return -1;
}
result = CALLOC (cmd_buf_size * 2, 1);
if (result == NULL) {
+ FREE (cmd);
+ gf_log ("parser", GF_LOG_ERROR, "Out of memory");
return -1;
}