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

Commitbd9396a

Browse files
committed
Avoid double-free in vacuumlo error path.
The code would do "PQclear(res)" twice if lo_unlink failed, evidentlydue to careless thinking about how far out a "break" would break.Remove the extra PQclear and adjust the loop logic so that we'll fallout of both levels of loop after an error, as was clearly the intent.Spotted by Coverity. I have no idea why it took this long to notice,since the bug has been there since commit67ccbb0. Accordingly,back-patch to all supported branches.
1 parent276d2e6 commitbd9396a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎contrib/vacuumlo/vacuumlo.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ vacuumlo(const char *database, const struct _param *param)
314314

315315
deleted=0;
316316

317-
while (1)
317+
do
318318
{
319319
res=PQexec(conn,buf);
320320
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
@@ -352,8 +352,7 @@ vacuumlo(const char *database, const struct _param *param)
352352
if (PQtransactionStatus(conn)==PQTRANS_INERROR)
353353
{
354354
success= false;
355-
PQclear(res);
356-
break;
355+
break;/* out of inner for-loop */
357356
}
358357
}
359358
else
@@ -391,7 +390,7 @@ vacuumlo(const char *database, const struct _param *param)
391390
}
392391

393392
PQclear(res);
394-
}
393+
}while (success);
395394

396395
/*
397396
* That's all folks!

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp