summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-11-24 21:51:47 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-11-24 23:15:11 +0100
commit3e35d7b316afda717d38b6efbe60bf580002ff9c (patch)
tree5ad7255fce714e469ac140c6b949bccd3f075ede
parentaa5676d1552bd8cd051acf5bd1f39141fb2e0b9f (diff)
downloadgmathlib-3e35d7b316afda717d38b6efbe60bf580002ff9c.tar.gz
gmathlib-3e35d7b316afda717d38b6efbe60bf580002ff9c.tar.bz2
* Sanitize to avoid problems if child is NULL in gmathsymbol_set_child
-rw-r--r--core/gmathlib.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/gmathlib.c b/core/gmathlib.c
index 189ba08..879f999 100644
--- a/core/gmathlib.c
+++ b/core/gmathlib.c
@@ -293,11 +293,13 @@ gmathsymbol_set_value (GMathSymbol *symbol, gchar *value)
void
gmathsymbol_set_child (GMathSymbol *symbol, GMathSymbol *child, int index)
{
- if (!symbol || child->parent || index >= symbol->template->children_count)
+ if (!symbol || (child && child->parent) ||
+ index >= symbol->template->children_count)
return;
symbol->children[index] = child;
- child->parent = symbol;
+ if (child)
+ child->parent = symbol;
}
/* Get a Symbol's child */