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

Commitb34c8ec

Browse files
committed
From: James Hughes <jamesh@interpath.com>
This is a patch to fix crashes in psql when executing queries froman external file. The code also adds error checking to verify thatmemory for "query" was allocated. The conditional for the block ofcode was changed from "query == NULL" to "query_alloced == false".The conditional, "query == NULL", was never true. This preventedthe memory being allocated for "query". A few lines later, an attemptto write to an un-allocated memory area generated a SIGSEGV causingthe frontend to crash.
1 parentb8476a0 commitb34c8ec

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/bin/psql/psql.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.128 1998/01/23 19:21:11 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.129 1998/01/23 19:22:24 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2093,10 +2093,15 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
20932093
intparen_level;
20942094
char*query_start;
20952095

2096-
if (query==NULL)
2096+
if (query_alloced==false)
20972097
{
2098-
query=malloc(MAX_QUERY_BUFFER);
2099-
query_alloced= true;
2098+
if((query=malloc(MAX_QUERY_BUFFER))==NULL) {
2099+
2100+
perror("Memory Allocation Failed");
2101+
2102+
}else {
2103+
query_alloced= true;
2104+
}
21002105
}
21012106

21022107
interactive= ((source==stdin)&& !pset->notty);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp