Skip to content

Commit

Permalink
fix segfaults in specific usages
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Sep 10, 2012
1 parent 6e32aff commit 37f287b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
8 changes: 6 additions & 2 deletions configs/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: ini.c 327425 2012-09-02 03:58:49Z laruence $ */
/* $Id: ini.c 327591 2012-09-10 10:56:13Z laruence $ */

zend_class_entry *yaf_config_ini_ce;

Expand Down Expand Up @@ -548,9 +548,13 @@ yaf_config_t * yaf_config_ini_instance(yaf_config_t *this_ptr, zval *filename, z
return NULL;
}
}
} else {
zval_ptr_dtor(&configs);
yaf_trigger_error(E_ERROR TSRMLS_CC, "Argument is not a valid ini file '%s'", ini_file);
return NULL;
}
} else {
efree(configs);
zval_ptr_dtor(&configs);
yaf_trigger_error(E_ERROR TSRMLS_CC, "Unable to find config file '%s'", ini_file);
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions requests/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: simple.c 327580 2012-09-10 06:31:34Z laruence $ */
/* $Id: simple.c 327591 2012-09-10 10:56:13Z laruence $ */

static zend_class_entry *yaf_request_simple_ce;

Expand All @@ -30,7 +30,7 @@ yaf_request_t * yaf_request_simple_instance(yaf_request_t *this_ptr, zval *modul
object_init_ex(instance, yaf_request_simple_ce);
}

if (!method) {
if (!method || IS_STRING != Z_TYPE_P(method)) {
MAKE_STD_ZVAL(method);
if (!SG(request_info).request_method) {
if (!strncasecmp(sapi_module.name, "cli", 3)) {
Expand Down
24 changes: 24 additions & 0 deletions tests/054.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
check for Various segfault
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
--FILE--
<?php
try {
$config = new Yaf_Config_Ini(dirname(__FILE__), "test");
} catch (Exception $e) {
var_dump($e->getMessage());
}

$request = new Yaf_Request_Simple(NULL);
var_dump($request->isOptions());

echo "okey";
?>
--EXPECTF--
string(%d) "Argument is not a valid ini file '%s'"
bool(false)
okey
4 changes: 2 additions & 2 deletions yaf_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_request.h 327552 2012-09-09 03:52:28Z laruence $ */
/* $Id: yaf_request.h 327591 2012-09-10 10:56:13Z laruence $ */

#ifndef YAF_REQUEST_H
#define YAF_REQUEST_H
Expand Down Expand Up @@ -44,7 +44,7 @@

#define YAF_REQUEST_IS_METHOD(x) \
PHP_METHOD(yaf_request, is##x) {\
zval * method = zend_read_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_METHOD), 1 TSRMLS_CC);\
zval * method = zend_read_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_METHOD), 0 TSRMLS_CC);\
if (strncasecmp(#x, Z_STRVAL_P(method), Z_STRLEN_P(method)) == 0) { \
RETURN_TRUE; \
} \
Expand Down

0 comments on commit 37f287b

Please sign in to comment.