Skip to content

Commit 04b4bf0

Browse files
committed
Merge pull request #567
2 parents aa3fb3e + f45916a commit 04b4bf0

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

src/contrib/php_array_api.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,20 +355,22 @@ char *php_array_zval_to_string(zval *z, int *plen, zend_bool *pfree) {
355355
*plen = 0;
356356
*pfree = 0;
357357
if (!z) { return NULL; }
358-
*pfree = 1;
359358
switch (Z_TYPE_P(z)) {
360359
case IS_NULL:
361-
*pfree = 0;
362360
return (char *)"";
363361
case IS_STRING:
364-
*pfree = 0;
365362
*plen = Z_STRLEN_P(z);
366363
return Z_STRVAL_P(z);
367364
default:
368365
{
369366
zval c = *z;
370367
zval_copy_ctor(&c);
371368
convert_to_string(&c);
369+
#ifdef ZEND_ENGINE_3
370+
*pfree = ! IS_INTERNED(Z_STR(c));
371+
#else
372+
*pfree = ! IS_INTERNED(Z_STRVAL(c));
373+
#endif
372374
*plen = Z_STRLEN(c);
373375
return Z_STRVAL(c);
374376
}

tests/manager/bug0940-001.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
PHPC-940: php_phongo_free_ssl_opt() attempts to free interned strings
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
var_dump(new MongoDB\Driver\Manager(null, [], ['ca_file' => false]));
9+
10+
?>
11+
===DONE===
12+
<?php exit(0); ?>
13+
--EXPECTF--
14+
object(MongoDB\Driver\Manager)#%d (%d) {
15+
["uri"]=>
16+
string(20) "mongodb://127.0.0.1/"
17+
["cluster"]=>
18+
array(0) {
19+
}
20+
}
21+
===DONE===

tests/manager/bug0940-002.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
PHPC-940: php_phongo_free_ssl_opt() attempts to free interned strings (context option)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
$context = stream_context_create(['ssl' => ['cafile' => false]]);
9+
10+
var_dump(new MongoDB\Driver\Manager(null, [], ['context' => $context]));
11+
12+
?>
13+
===DONE===
14+
<?php exit(0); ?>
15+
--EXPECTF--
16+
object(MongoDB\Driver\Manager)#%d (%d) {
17+
["uri"]=>
18+
string(20) "mongodb://127.0.0.1/"
19+
["cluster"]=>
20+
array(0) {
21+
}
22+
}
23+
===DONE===

0 commit comments

Comments
 (0)