diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-04-08 00:30:54 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-04-08 00:31:58 -0400 |
commit | b6bc481d5540a3ad0d39db1e9881e6bd52e54213 (patch) | |
tree | 7d8f0382c1e9fc12a430d395b4838d6a2e263c92 | |
parent | a53112338c2f5b74383ce075fbec098cd06a3ad7 (diff) | |
download | postgresql-b6bc481d5540a3ad0d39db1e9881e6bd52e54213.tar.gz postgresql-b6bc481d5540a3ad0d39db1e9881e6bd52e54213.zip |
Fix some sloppiness in new PL/python get_source_line() function.
Jan UrbaĆski
-rw-r--r-- | src/pl/plpython/plpython.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 935258044db..47d898a9765 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -4484,12 +4484,11 @@ cleanup: static char * get_source_line(const char *src, int lineno) { - const char *s; - const char *next; - int current = 0; + const char *s = NULL; + const char *next = src; + int current = 0; - next = src; - while (current != lineno) + while (current < lineno) { s = next; next = strchr(s + 1, '\n'); @@ -4501,7 +4500,7 @@ get_source_line(const char *src, int lineno) if (current != lineno) return NULL; - while (s && isspace((unsigned char) *s)) + while (*s && isspace((unsigned char) *s)) s++; if (next == NULL) |