Skip to content

Commit 1aee7ad

Browse files
committed
Fixed bug #64934 Apache2 TS crash with get_browser()
In favour of reading the browscap.ini into a true global var only once in MINIT, the price for that is to deep copy the any data from it.
1 parent ec3bcbc commit 1aee7ad

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2013, PHP 5.3.27
44
- Core:
55
. Fixed bug #64960 (Segfault in gc_zval_possible_root). (Laruence)
6+
. Fixed bug #64934 (Apache2 TS crash with get_browser()). (Anatol)
67

78
- PDO_firebird:
89
. Fixed bug #64037 (Firebird return wrong value for numeric field).

ext/standard/browscap.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,19 @@ static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list a
451451
}
452452
/* }}} */
453453

454+
static void browscap_zval_copy_ctor(zval **p) /* {{{ */
455+
{
456+
zval *new;
457+
458+
ALLOC_ZVAL(new);
459+
*new = **p;
460+
461+
zval_copy_ctor(new);
462+
463+
INIT_PZVAL(new);
464+
*p = new;
465+
} /* }}} */
466+
454467
/* {{{ proto mixed get_browser([string browser_name [, bool return_array]])
455468
Get information about the capabilities of a browser. If browser_name is omitted or null, HTTP_USER_AGENT is used. Returns an object by default; if return_array is true, returns an array. */
456469
PHP_FUNCTION(get_browser)
@@ -511,11 +524,11 @@ PHP_FUNCTION(get_browser)
511524

512525
if (return_array) {
513526
array_init(return_value);
514-
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
527+
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *));
515528
}
516529
else {
517530
object_init(return_value);
518-
zend_hash_copy(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
531+
zend_hash_copy(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *));
519532
}
520533

521534
while (zend_hash_find(Z_ARRVAL_PP(agent), "parent", sizeof("parent"), (void **) &z_agent_name) == SUCCESS) {
@@ -524,10 +537,10 @@ PHP_FUNCTION(get_browser)
524537
}
525538

526539
if (return_array) {
527-
zend_hash_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *), 0);
540+
zend_hash_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *), 0);
528541
}
529542
else {
530-
zend_hash_merge(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *), 0);
543+
zend_hash_merge(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *), 0);
531544
}
532545
}
533546

0 commit comments

Comments
 (0)