Committed by Greg Sabino Mullane <[email protected]>
Better logic inside of pg_st_split_statement for the end of the string.
Per talk on RT 79035.
In a nutshell, we cannot look at *statement, which is one past the current
character (ch), if we know what we have already reached the end of the
string because ch == '\0'. This was (quite understanably!) causing segfaults
on some platforms. Another set of eyes for reviewing welcome (hi Davids)
---
dbdimp.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/dbdimp.c b/dbdimp.c
index 84caa8e..ec84e46 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -1973,8 +1973,12 @@ static void pg_st_split_statement (pTHX_ imp_sth_t *
imp_sth, int version, char
if (placeholder_type > 0)
imp_sth->placeholder_type = placeholder_type;
- /* If this segment also, ended the string, set ch so we bail
out early */
- if ('\0' == *statement)
+ /*
+ Check if this segment also ends the string.
+ If it does, we simply leave right away.
+ Make sure we don't peek at statement if we know it is past
the end of the string.
+ */
+ if ('\0' != ch && '\0' == *statement)
break;
} /* end large while(1) loop: statement parsing */
--
1.7.1