Skip to content

Commit 2d4b973

Browse files
author
Neil Conway
committed
Trivial dead code removal: in _complete_from_query(), 'text' cannot be
NULL (e.g. due to the preceding strlen()). Therefore we needn't recheck this before initializing 'e_text'. Per Coverity static analysis performed by EnterpriseDB.
1 parent 141e878 commit 2d4b973

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/bin/psql/tab-complete.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.131 2005/06/14 17:43:14 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.132 2005/06/21 00:48:33 neilc Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -1909,13 +1909,8 @@ _complete_from_query(int is_schema_query, const char *text, int state)
19091909
result = NULL;
19101910

19111911
/* Set up suitably-escaped copies of textual inputs */
1912-
if (text)
1913-
{
1914-
e_text = pg_malloc(strlen(text) *2 + 1);
1915-
PQescapeString(e_text, text, strlen(text));
1916-
}
1917-
else
1918-
e_text = NULL;
1912+
e_text = pg_malloc(string_length * 2 + 1);
1913+
PQescapeString(e_text, text, string_length);
19191914

19201915
if (completion_info_charp)
19211916
{
@@ -2035,9 +2030,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
20352030
result = exec_query(query_buffer.data);
20362031

20372032
termPQExpBuffer(&query_buffer);
2038-
2039-
if (e_text)
2040-
free(e_text);
2033+
free(e_text);
20412034
if (e_info_charp)
20422035
free(e_info_charp);
20432036
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy