[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [labplot] src/backend/gsl: Fixed memleak in the parser.
From:       Alexander Semke <alexander.semke () web ! de>
Date:       2014-08-31 18:33:26
Message-ID: E1XO9wM-00017m-NL () scm ! kde ! org
[Download RAW message or body]

Git commit 893c195db1778f141f42ddc4a0e823319b1766ac by Alexander Semke.
Committed on 31/08/2014 at 18:33.
Pushed by asemke into branch 'master'.

Fixed memleak in the parser.

M  +6    -5    src/backend/gsl/parser.tab.c
M  +6    -5    src/backend/gsl/parser.y.linux

http://commits.kde.org/labplot/893c195db1778f141f42ddc4a0e823319b1766ac

diff --git a/src/backend/gsl/parser.tab.c b/src/backend/gsl/parser.tab.c
index ef74dd3..405996f 100644
--- a/src/backend/gsl/parser.tab.c
+++ b/src/backend/gsl/parser.tab.c
@@ -1842,7 +1842,7 @@ symrec* assign_variable(const char* symb_name, double value) {
 #ifdef LDEBUG
 	printf("		calling putsym() : symb_name = %s\n",symb_name);
 #endif
-		
+
 		ptr = putsym(symb_name,VAR);
 	}
 
@@ -1866,9 +1866,6 @@ static void ungetcstr(void) {
 }
 
 int yylex (void) {
-	/* use same locale for all languages: '.' as decimal point */
-	locale_t locale = newlocale (LC_NUMERIC_MASK, "C", NULL);
-
 #ifdef LDEBUG
 	printf("	yylex()\n");
 #endif
@@ -1897,9 +1894,13 @@ int yylex (void) {
                 ungetcstr();
                 char *s = &string[pos];
 
+		/* use same locale for all languages: '.' as decimal point */
+		locale_t locale = newlocale (LC_NUMERIC_MASK, "C", NULL);
+
 		/* convert to double */
 		char *remain;
 		double result = strtod_l(s,&remain,locale);
+		freelocale(locale);
 #ifdef LDEBUG
 		printf("		reading: %s",s);
 		printf("		remain = %s",remain);
@@ -1911,7 +1912,7 @@ int yylex (void) {
 		printf("		result = %g\n",result);
 #endif
 		yylval.dval=result;
-		
+
                 pos += strlen(s)-strlen(remain);
 
 		return NUM;
diff --git a/src/backend/gsl/parser.y.linux b/src/backend/gsl/parser.y.linux
index 38c1fe3..3e6fb1f 100644
--- a/src/backend/gsl/parser.y.linux
+++ b/src/backend/gsl/parser.y.linux
@@ -171,7 +171,7 @@ symrec* assign_variable(const char* symb_name, double value) {
 #ifdef LDEBUG
 	printf("		calling putsym() : symb_name = %s\n",symb_name);
 #endif
-		
+
 		ptr = putsym(symb_name,VAR);
 	}
 
@@ -195,9 +195,6 @@ static void ungetcstr(void) {
 }
 
 int yylex (void) {
-	/* use same locale for all languages: '.' as decimal point */
-	locale_t locale = newlocale (LC_NUMERIC_MASK, "C", NULL);
-
 #ifdef LDEBUG
 	printf("	yylex()\n");
 #endif
@@ -226,9 +223,13 @@ int yylex (void) {
                 ungetcstr();
                 char *s = &string[pos];
 
+		/* use same locale for all languages: '.' as decimal point */
+		locale_t locale = newlocale (LC_NUMERIC_MASK, "C", NULL);
+
 		/* convert to double */
 		char *remain;
 		double result = strtod_l(s,&remain,locale);
+		freelocale(locale);
 #ifdef LDEBUG
 		printf("		reading: %s",s);
 		printf("		remain = %s",remain);
@@ -240,7 +241,7 @@ int yylex (void) {
 		printf("		result = %g\n",result);
 #endif
 		yylval.dval=result;
-		
+
                 pos += strlen(s)-strlen(remain);
 
 		return NUM;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic