diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-01-21 18:43:25 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-01-21 18:43:25 +0000 |
commit | b13da41eba0af3d7f3e9bc68b9e69a97fa25ac4b (patch) | |
tree | 4f742a9899376fe3974a22f261c0b22aff519cf7 | |
parent | d66679672f22de7360514f26cb81ccdb5ab43096 (diff) | |
download | postgresql-b13da41eba0af3d7f3e9bc68b9e69a97fa25ac4b.tar.gz postgresql-b13da41eba0af3d7f3e9bc68b9e69a97fa25ac4b.zip |
Fix unsafe loop test, and declare as_ident as bool rather than int.
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index bbcf11a687a..2e5551d31e5 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.207 2010/01/21 14:58:53 rhaas Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.208 2010/01/21 18:43:25 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -3066,7 +3066,7 @@ PQescapeString(char *to, const char *from, size_t length) * of memory condition, we return NULL, storing an error message into conn. */ static char * -PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident) +PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident) { const char *s; char *result; @@ -3082,7 +3082,7 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident) return NULL; /* Scan the string for characters that must be escaped. */ - for (s = str; *s != '\0' && (s - str) < len; ++s) + for (s = str; (s - str) < len && *s != '\0'; ++s) { if (*s == quote_char) ++num_quotes; @@ -3188,13 +3188,13 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident) char * PQescapeLiteral(PGconn *conn, const char *str, size_t len) { - return PQescapeInternal(conn, str, len, 0); + return PQescapeInternal(conn, str, len, false); } char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len) { - return PQescapeInternal(conn, str, len, 1); + return PQescapeInternal(conn, str, len, true); } /* HEX encoding support for bytea */ |