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

Fixed PHP-1435: MongoCollection::getIndexInfo on non-existing collection segfaults #847

Merged
merged 1 commit into from
Apr 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions collection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,7 @@ void mongo_collection_list_indexes_command(zval *this_ptr, zval *return_value TS
if (Z_TYPE_P(code) == IS_LONG && Z_LVAL_P(code) == PHP_MONGO_COLLECTION_DOES_NOT_EXIST) {
zend_clear_exception(TSRMLS_C);
zval_ptr_dtor(&retval);
MAKE_STD_ZVAL(retval);
array_init(retval);
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/standalone/bug01435.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Test for PHP-1435: MongoCollection::getIndexInfo on non-existing collection segfaults
--SKIPIF--
<?php require_once "tests/utils/standalone.inc" ?>
--FILE--
<?php
require_once "tests/utils/server.inc";

$host = MongoShellServer::getStandaloneInfo();
$m = new MongoClient($host);
$c = $m->selectCollection('doesnotexist', 'doesnotexist');
$i = $c->getIndexInfo();
$m->close();
var_dump($i);
?>
==DONE==
--EXPECTF--
array(0) {
}
==DONE==