summaryrefslogtreecommitdiff
path: root/ext/pgsql/pgsql.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-04-04 10:25:12 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-04-04 10:25:12 +0000
commit186823957aa76c1e844bce8e83e2e6e6525ad4b8 (patch)
treed6930ea9a0e623cd1fe22856157c93bad362be78 /ext/pgsql/pgsql.c
parente50a42f907bf235d403c6979cef20ab87e76e023 (diff)
downloadphp-git-186823957aa76c1e844bce8e83e2e6e6525ad4b8.tar.gz
Fixed crash with pg_escape_*()
# I'll MFH later.
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r--ext/pgsql/pgsql.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 1654f58d5a..934e0413b7 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -2397,8 +2397,10 @@ PHP_FUNCTION(pg_escape_string)
return;
}
+ to = (char *)emalloc(len*2+1);
len = (int)PQescapeString(to, from, strlen(from));
if (len < 0) {
+ efree(to);
RETURN_FALSE;
}
RETURN_STRINGL(to, len, 0);
@@ -2418,9 +2420,11 @@ PHP_FUNCTION(pg_escape_bytea)
to = (char *)PQescapeBytea((unsigned char*)from, strlen(from), (size_t *)&len);
if (len < 0) {
+ /* Don't need to free "to" here*/
RETURN_FALSE;
}
- RETURN_STRINGL(to, len, 0);
+ RETURN_STRINGL(to, len, 1);
+ free(to);
}
/* }}} */
#endif