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

Commit1acab12

Browse files
committed
Remove memory leaks in isolationtester.
specscanner.l leaked a kilobyte of memory per token of the spec file.Apparently somebody thought that the introductory code block would beexecuted once; but it's once per yylex() call.A couple of functions in isolationtester.c leaked small amounts ofmemory due to not bothering to free one-time allocations. Mightas well improve these so that valgrind gives this program a cleanbill of health. Also get rid of an ugly static variable.Coverity complained about one of the one-time leaks, which led meto try valgrind'ing isolationtester, which led to discovery of thelarger leak.
1 parentdcb0e24 commit1acab12

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ static void exit_nicely(void) pg_attribute_noreturn();
5454
staticvoidcheck_testspec(TestSpec*testspec);
5555
staticvoidrun_testspec(TestSpec*testspec);
5656
staticvoidrun_all_permutations(TestSpec*testspec);
57-
staticvoidrun_all_permutations_recurse(TestSpec*testspec,intnsteps,
58-
PermutationStep**steps);
57+
staticvoidrun_all_permutations_recurse(TestSpec*testspec,int*piles,
58+
intnsteps,PermutationStep**steps);
5959
staticvoidrun_named_permutations(TestSpec*testspec);
6060
staticvoidrun_permutation(TestSpec*testspec,intnsteps,
6161
PermutationStep**steps);
@@ -366,9 +366,9 @@ check_testspec(TestSpec *testspec)
366366
fprintf(stderr,"unused step name: %s\n",allsteps[i]->name);
367367
}
368368
}
369-
}
370369

371-
staticint*piles;
370+
free(allsteps);
371+
}
372372

373373
/*
374374
* Run the permutations specified in the spec, or all if none were
@@ -393,6 +393,7 @@ run_all_permutations(TestSpec *testspec)
393393
inti;
394394
PermutationStep*steps;
395395
PermutationStep**stepptrs;
396+
int*piles;
396397

397398
/* Count the total number of steps in all sessions */
398399
nsteps=0;
@@ -418,11 +419,16 @@ run_all_permutations(TestSpec *testspec)
418419
for (i=0;i<testspec->nsessions;i++)
419420
piles[i]=0;
420421

421-
run_all_permutations_recurse(testspec,0,stepptrs);
422+
run_all_permutations_recurse(testspec,piles,0,stepptrs);
423+
424+
free(steps);
425+
free(stepptrs);
426+
free(piles);
422427
}
423428

424429
staticvoid
425-
run_all_permutations_recurse(TestSpec*testspec,intnsteps,PermutationStep**steps)
430+
run_all_permutations_recurse(TestSpec*testspec,int*piles,
431+
intnsteps,PermutationStep**steps)
426432
{
427433
inti;
428434
boolfound= false;
@@ -444,7 +450,7 @@ run_all_permutations_recurse(TestSpec *testspec, int nsteps, PermutationStep **s
444450

445451
piles[i]++;
446452

447-
run_all_permutations_recurse(testspec,nsteps+1,steps);
453+
run_all_permutations_recurse(testspec,piles,nsteps+1,steps);
448454

449455
piles[i]--;
450456

‎src/test/isolation/specscanner.l

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ self[,()*]
5252
%%
5353

5454
%{
55-
litbuf = pg_malloc(LITBUF_INIT);
56-
litbufsize = LITBUF_INIT;
55+
/* Allocate litbuf in first call of yylex()*/
56+
if (litbuf ==NULL)
57+
{
58+
litbuf =pg_malloc(LITBUF_INIT);
59+
litbufsize = LITBUF_INIT;
60+
}
5761
%}
5862

5963
/* Keywords (must appear before the {identifier} rule!) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp