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

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ main(void)
211211
printf("num[d,%d,%d]: %s\n",i,j,text);
212212
free(text);
213213
}
214+
215+
PGTYPESnumeric_free(a);
216+
PGTYPESnumeric_free(s);
217+
PGTYPESnumeric_free(m);
218+
PGTYPESnumeric_free(d);
214219
}
215220
}
216221

@@ -219,7 +224,9 @@ main(void)
219224
text=PGTYPESnumeric_to_asc(numarr[i],-1);
220225
printf("%d: %s\n",i,text);
221226
free(text);
227+
PGTYPESnumeric_free(numarr[i]);
222228
}
229+
free(numarr);
223230

224231
return (0);
225232
}

‎src/interfaces/ecpg/test/expected/sql-array.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,5 +273,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
273273
#line 74 "array.pgc"
274274

275275

276+
free(t);
277+
276278
return (0);
277279
}

‎src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ main(void)
4949
PGTYPESinterval_copy(iv1, &iv2);
5050
text = PGTYPESinterval_to_asc(&iv2);
5151
printf ("interval: %s\n", text);
52+
PGTYPESinterval_free(iv1);
5253
free(text);
5354

5455
PGTYPESdate_mdyjul(mdy, &date2);

‎src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ main(void)
104104
printf("TS[%d,%d]: %s\n",
105105
i, j, errno ? "-" : text);
106106
free(text);
107+
free(t);
107108
}
108109
}
109110
}
@@ -134,6 +135,7 @@ main(void)
134135
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
135136
free(text);
136137
PGTYPESinterval_free(ic);
138+
PGTYPESinterval_free(i1);
137139
}
138140

139141
return (0);

‎src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ main(void)
8383
}
8484
exec sql close cur1;
8585

86+
PGTYPESnumeric_free(num);
87+
8688
exec sql rollback;
8789
exec sql disconnect;
8890

‎src/interfaces/ecpg/test/pgtypeslib/num_test.pgc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ main(void)
7777
PGTYPESnumeric_to_double(res, &d);
7878
printf("div = %s %e\n", text, d);
7979

80+
PGTYPESnumeric_free(value1);
81+
PGTYPESnumeric_free(value2);
82+
8083
value1 = PGTYPESnumeric_from_asc("2E7", NULL);
8184
value2 = PGTYPESnumeric_from_asc("14", NULL);
8285
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);

‎src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ main(void)
193193
printf("num[d,%d,%d]: %s\n", i, j, text);
194194
free(text);
195195
}
196+
197+
PGTYPESnumeric_free(a);
198+
PGTYPESnumeric_free(s);
199+
PGTYPESnumeric_free(m);
200+
PGTYPESnumeric_free(d);
196201
}
197202
}
198203

@@ -201,7 +206,9 @@ main(void)
201206
text = PGTYPESnumeric_to_asc(numarr[i], -1);
202207
printf("%d: %s\n", i, text);
203208
free(text);
209+
PGTYPESnumeric_free(numarr[i]);
204210
}
211+
free(numarr);
205212

206213
return (0);
207214
}

‎src/interfaces/ecpg/test/sql/array.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,7 @@ EXEC SQL END DECLARE SECTION;
7373

7474
EXEC SQL DISCONNECT;
7575

76+
free(t);
77+
7678
return (0);
7779
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp