Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 9ace894

Browse files
committed
Merged pull request #847
2 parents befdc85 + 4342d41 commit 9ace894

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

collection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,7 @@ void mongo_collection_list_indexes_command(zval *this_ptr, zval *return_value TS
20882088
if (Z_TYPE_P(code) == IS_LONG && Z_LVAL_P(code) == PHP_MONGO_COLLECTION_DOES_NOT_EXIST) {
20892089
zend_clear_exception(TSRMLS_C);
20902090
zval_ptr_dtor(&retval);
2091+
MAKE_STD_ZVAL(retval);
20912092
array_init(retval);
20922093
}
20932094
}

tests/standalone/bug01435.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for PHP-1435: MongoCollection::getIndexInfo on non-existing collection segfaults
3+
--SKIPIF--
4+
<?php require_once "tests/utils/standalone.inc" ?>
5+
--FILE--
6+
<?php
7+
require_once "tests/utils/server.inc";
8+
9+
$host = MongoShellServer::getStandaloneInfo();
10+
$m = new MongoClient($host);
11+
$c = $m->selectCollection('doesnotexist', 'doesnotexist');
12+
$i = $c->getIndexInfo();
13+
$m->close();
14+
var_dump($i);
15+
?>
16+
==DONE==
17+
--EXPECTF--
18+
array(0) {
19+
}
20+
==DONE==

0 commit comments

Comments
 (0)