Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a8d15b

Browse files
author
Michael Meskes
committed
Applied Zoltan's patch to fix a few memleaks in ecpg's pgtypeslib.
1 parent7b243aa commit9a8d15b

18 files changed

+63
-18
lines changed

‎src/interfaces/ecpg/pgtypeslib/numeric.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.35 2010/02/02 16:09:12 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.36 2010/08/1709:36:04 meskes Exp $ */
22

33
#include"postgres_fe.h"
44
#include<ctype.h>
@@ -417,7 +417,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
417417
ret=set_var_from_str(str,ptr,value);
418418
if (ret)
419419
{
420-
free(value);
420+
PGTYPESnumeric_free(value);
421421
return (NULL);
422422
}
423423

@@ -1602,8 +1602,12 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
16021602
errno=0;
16031603
*lp=strtol(s,&endptr,10);
16041604
if (endptr==s)
1605+
{
16051606
/* this should not happen actually */
1607+
free(s);
16061608
return-1;
1609+
}
1610+
free(s);
16071611
if (errno==ERANGE)
16081612
{
16091613
if (*lp==LONG_MIN)
@@ -1612,7 +1616,6 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
16121616
errno=PGTYPES_NUM_OVERFLOW;
16131617
return-1;
16141618
}
1615-
free(s);
16161619
return0;
16171620
}
16181621

‎src/interfaces/ecpg/test/compat_informix/dec_test.pgc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ main(void)
6060
{
6161
check_errno();
6262
printf("dec[%d,0]: r: %d\n", i, r);
63+
PGTYPESdecimal_free(dec);
6364
continue;
6465
}
6566
decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
@@ -200,7 +201,10 @@ main(void)
200201
{
201202
dectoasc(decarr[i], buf, BUFSIZE-1, -1);
202203
printf("%d: %s\n", i, buf);
204+
205+
PGTYPESdecimal_free(decarr[i]);
203206
}
207+
free(decarr);
204208

205209
return (0);
206210
}

‎src/interfaces/ecpg/test/expected/compat_informix-dec_test.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ main(void)
8080
{
8181
check_errno();
8282
printf("dec[%d,0]: r: %d\n",i,r);
83+
PGTYPESdecimal_free(dec);
8384
continue;
8485
}
8586
decarr=realloc(decarr,sizeof(decimal*)* (count+1));
@@ -220,7 +221,10 @@ main(void)
220221
{
221222
dectoasc(decarr[i],buf,BUFSIZE-1,-1);
222223
printf("%d: %s\n",i,buf);
224+
225+
PGTYPESdecimal_free(decarr[i]);
223226
}
227+
free(decarr);
224228

225229
return (0);
226230
}

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
123123
PGTYPESinterval_copy(iv1,&iv2);
124124
text=PGTYPESinterval_to_asc(&iv2);
125125
printf ("interval: %s\n",text);
126+
PGTYPESinterval_free(iv1);
126127
free(text);
127128

128129
PGTYPESdate_mdyjul(mdy,&date2);
@@ -430,16 +431,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
430431
free(text);
431432

432433
{ECPGtrans(__LINE__,NULL,"rollback");
433-
#line358 "dt_test.pgc"
434+
#line359 "dt_test.pgc"
434435

435436
if (sqlca.sqlcode<0)sqlprint ( );}
436-
#line358 "dt_test.pgc"
437+
#line359 "dt_test.pgc"
437438

438439
{ECPGdisconnect(__LINE__,"CURRENT");
439-
#line359 "dt_test.pgc"
440+
#line360 "dt_test.pgc"
440441

441442
if (sqlca.sqlcode<0)sqlprint ( );}
442-
#line359 "dt_test.pgc"
443+
#line360 "dt_test.pgc"
443444

444445

445446
return (0);

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
[NO_PID]: sqlca: code: 0, state: 00000
4343
[NO_PID]: ecpg_get_data on line 38: RESULT: 2000-07-12 17:34:29 offset: -1; array: no
4444
[NO_PID]: sqlca: code: 0, state: 00000
45-
[NO_PID]: ECPGtrans on line358: action "rollback"; connection "regress1"
45+
[NO_PID]: ECPGtrans on line359: action "rollback"; connection "regress1"
4646
[NO_PID]: sqlca: code: 0, state: 00000
4747
[NO_PID]: ecpg_finish: connection regress1 closed
4848
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ main(void)
139139
printf("TS[%d,%d]: %s\n",
140140
i,j,errno ?"-" :text);
141141
free(text);
142+
free(t);
142143
}
143144
}
144145
}
@@ -169,6 +170,7 @@ main(void)
169170
printf("interval_copy[%d]: %s\n",i,text ?text :"-");
170171
free(text);
171172
PGTYPESinterval_free(ic);
173+
PGTYPESinterval_free(i1);
172174
}
173175

174176
return (0);

‎src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,19 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
252252
#line 84 "nan_test.pgc"
253253

254254

255+
PGTYPESnumeric_free(num);
256+
255257
{ECPGtrans(__LINE__,NULL,"rollback");
256-
#line86 "nan_test.pgc"
258+
#line88 "nan_test.pgc"
257259

258260
if (sqlca.sqlcode<0)sqlprint ( );}
259-
#line86 "nan_test.pgc"
261+
#line88 "nan_test.pgc"
260262

261263
{ECPGdisconnect(__LINE__,"CURRENT");
262-
#line87 "nan_test.pgc"
264+
#line89 "nan_test.pgc"
263265

264266
if (sqlca.sqlcode<0)sqlprint ( );}
265-
#line87 "nan_test.pgc"
267+
#line89 "nan_test.pgc"
266268

267269

268270
return (0);

‎src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
[NO_PID]: sqlca: code: 0, state: 00000
355355
[NO_PID]: ecpg_execute on line 84: OK: CLOSE CURSOR
356356
[NO_PID]: sqlca: code: 0, state: 00000
357-
[NO_PID]: ECPGtrans on line86: action "rollback"; connection "regress1"
357+
[NO_PID]: ECPGtrans on line88: action "rollback"; connection "regress1"
358358
[NO_PID]: sqlca: code: 0, state: 00000
359359
[NO_PID]: ecpg_finish: connection regress1 closed
360360
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
131131
PGTYPESnumeric_to_double(res,&d);
132132
printf("div = %s %e\n",text,d);
133133

134+
PGTYPESnumeric_free(value1);
135+
PGTYPESnumeric_free(value2);
136+
134137
value1=PGTYPESnumeric_from_asc("2E7",NULL);
135138
value2=PGTYPESnumeric_from_asc("14",NULL);
136139
i=PGTYPESnumeric_to_long(value1,&l1) |PGTYPESnumeric_to_long(value2,&l2);
@@ -142,16 +145,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
142145
PGTYPESnumeric_free(res);
143146

144147
{ECPGtrans(__LINE__,NULL,"rollback");
145-
#line90 "num_test.pgc"
148+
#line93 "num_test.pgc"
146149

147150
if (sqlca.sqlcode<0)sqlprint ( );}
148-
#line90 "num_test.pgc"
151+
#line93 "num_test.pgc"
149152

150153
{ECPGdisconnect(__LINE__,"CURRENT");
151-
#line91 "num_test.pgc"
154+
#line94 "num_test.pgc"
152155

153156
if (sqlca.sqlcode<0)sqlprint ( );}
154-
#line91 "num_test.pgc"
157+
#line94 "num_test.pgc"
155158

156159

157160
return (0);

‎src/interfaces/ecpg/test/expected/pgtypeslib-num_test.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
[NO_PID]: sqlca: code: 0, state: 00000
2727
[NO_PID]: ecpg_get_data on line 66: RESULT: 2369.7000000 offset: -1; array: no
2828
[NO_PID]: sqlca: code: 0, state: 00000
29-
[NO_PID]: ECPGtrans on line90: action "rollback"; connection "regress1"
29+
[NO_PID]: ECPGtrans on line93: action "rollback"; connection "regress1"
3030
[NO_PID]: sqlca: code: 0, state: 00000
3131
[NO_PID]: ecpg_finish: connection regress1 closed
3232
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp