Skip to content

Commit 713dc5a

Browse files
committed
PHPC-159: memleak on failed path resolving
1 parent ced7c40 commit 713dc5a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

php_phongo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
888888
if (!stream) {
889889
bson_set_error (error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_CONNECT, "Failed connecting to '%s:%d': %s", host->host, host->port, errmsg);
890890
efree(dsn);
891+
if (errmsg) {
892+
efree(errmsg);
893+
}
891894
return NULL;
892895
}
893896

tests/standalone/bug0159.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
PHPC-159: Memleak on failed path resolving
3+
--SKIPIF--
4+
<?php require "tests/utils/basic-skipif.inc" ?>
5+
--FILE--
6+
<?php
7+
require_once "tests/utils/basic.inc";
8+
9+
$uri = parse_url(MONGODB_URI);
10+
$manager = new MongoDB\Driver\Manager("mongodb:///tmp/mongodb-27018.sock,{$uri["host"]}:{$uri["port"]}");
11+
$manager->executeQuery("foo.bar", new MongoDB\Driver\Query([]));
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECT--
17+
===DONE===
18+

0 commit comments

Comments
 (0)