Skip to content

Commit f8940e3

Browse files
committed
Fix _pdo_pgsql_trim_message bad access
1 parent f94c11f commit f8940e3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ static bool pgsql_handle_in_transaction(pdo_dbh_t *dbh);
3838

3939
static char * _pdo_pgsql_trim_message(const char *message, int persistent)
4040
{
41-
size_t i = strlen(message)-1;
41+
size_t i = strlen(message);
4242
char *tmp;
43+
if (i == 0) {
44+
tmp = pemalloc(1, persistent);
45+
tmp[0] = '\0';
46+
return tmp;
47+
}
48+
--i;
4349

4450
if (i>1 && (message[i-1] == '\r' || message[i-1] == '\n') && message[i] == '.') {
4551
--i;

0 commit comments

Comments
 (0)