Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 96ad72d

Browse files
author
Michael Meskes
committed
Fixed some memory leaks in ECPG.
Patch by Michael Paquier
1 parent 82be1bf commit 96ad72d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ output_get_descr(char *desc_name, char *index)
175175
for (results = assignments; results != NULL; results = results->next)
176176
{
177177
const struct variable *v = find_variable(results->variable);
178+
char *str_zero = mm_strdup("0");
178179

179180
switch (results->value)
180181
{
@@ -188,7 +189,8 @@ output_get_descr(char *desc_name, char *index)
188189
break;
189190
}
190191
fprintf(yyout, "%s,", get_dtype(results->value));
191-
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, mm_strdup("0"), NULL, NULL);
192+
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, str_zero, NULL, NULL);
193+
free(str_zero);
192194
}
193195
drop_assignments();
194196
fputs("ECPGd_EODT);\n", yyout);
@@ -292,8 +294,12 @@ output_set_descr(char *desc_name, char *index)
292294
case ECPGd_indicator:
293295
case ECPGd_length:
294296
case ECPGd_type:
295-
fprintf(yyout, "%s,", get_dtype(results->value));
296-
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, mm_strdup("0"), NULL, NULL);
297+
{
298+
char *str_zero = mm_strdup("0");
299+
fprintf(yyout, "%s,", get_dtype(results->value));
300+
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, str_zero, NULL, NULL);
301+
free(str_zero);
302+
}
297303
break;
298304

299305
default:

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
extern YYSTYPE yylval;
2828

2929
static int xcdepth = 0; /* depth of nesting in slash-star comments */
30-
static char *dolqstart; /* current $foo$ quote start string */
30+
static char *dolqstart = NULL; /* current $foo$ quote start string */
3131
static YY_BUFFER_STATE scanbufhandle;
3232
static char *scanbuf;
3333

@@ -550,6 +550,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
550550
}
551551
<SQL>{dolqdelim} {
552552
token_start = yytext;
553+
if (dolqstart)
554+
free(dolqstart);
553555
dolqstart = mm_strdup(yytext);
554556
BEGIN(xdolq);
555557
startlit();

src/interfaces/ecpg/preproc/variable.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,13 @@ remove_variable_from_list(struct arguments ** list, struct variable * var)
437437
void
438438
dump_variables(struct arguments * list, int mode)
439439
{
440-
char *str_zero = mm_strdup("0");
440+
char *str_zero;
441441

442442
if (list == NULL)
443443
return;
444444

445+
str_zero = mm_strdup("0");
446+
445447
/*
446448
* The list is build up from the beginning so lets first dump the end of
447449
* the list:

0 commit comments

Comments
 (0)