From 3037be8a1e09d27d6150027b28e48738dbac0db1 Mon Sep 17 00:00:00 2001 From: reinelt Date: Thu, 26 Feb 2004 21:42:45 +0000 Subject: [lcd4linux @ 2004-02-26 21:42:45 by reinelt] memory leak fixes from Martin git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@377 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- evaluator.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/evaluator.c b/evaluator.c index 9d497e7..17fee4c 100644 --- a/evaluator.c +++ b/evaluator.c @@ -1,4 +1,4 @@ -/* $Id: evaluator.c,v 1.12 2004/02/05 07:10:23 reinelt Exp $ +/* $Id: evaluator.c,v 1.13 2004/02/26 21:42:45 reinelt Exp $ * * expression evaluation * @@ -10,6 +10,9 @@ * FIXME: GPL or not GPL???? * * $Log: evaluator.c,v $ + * Revision 1.13 2004/02/26 21:42:45 reinelt + * memory leak fixes from Martin + * * Revision 1.12 2004/02/05 07:10:23 reinelt * evaluator function names are no longer case-sensitive * Crystalfontz Fan PWM control, Fan RPM monitoring, temperature monitoring @@ -316,6 +319,7 @@ char* R2S (RESULT *result) if (result->type & R_NUMBER) { sprintf(buffer, "%g", result->number); result->type |= R_STRING; + if (result->string) free(result->string); result->string=strdup(buffer); return result->string; } @@ -370,8 +374,13 @@ static int GetVariable (char *name, RESULT *value) if (V!=NULL) { value->type=V->value->type; value->number=V->value->number; - if (V->value->string!=NULL) value->string=strdup(V->value->string); - else value->string=NULL; + if(value->string) { + free(value->string); + value->string=0; + } + if (V->value->string!=NULL) { + value->string=strdup(V->value->string); + } return 1; } -- cgit v1.2.3