From: Michael Wallner Date: Wed, 17 Sep 2014 07:23:45 +0000 (+0200) Subject: guard against uninitialized property write, too X-Git-Tag: v0.5.0~19 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d96d8d4af09d7f32fec302908a5e4ee8d8bee7fb;p=m6w6%2Fext-pq guard against uninitialized property write, too use php_error with E_RECOVERABLE_ERROR --- diff --git a/src/php_pq_object.c b/src/php_pq_object.c index ecfbbf7..77207ea 100644 --- a/src/php_pq_object.c +++ b/src/php_pq_object.c @@ -114,12 +114,12 @@ zval *php_pq_object_read_prop(zval *object, zval *member, int type, const zend_l zval *return_value = NULL; if (!obj->intern) { - zend_error(E_WARNING, "%s not initialized", ancestor(obj->zo.ce)->name); + php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name); return_value = zend_get_std_object_handlers()->read_property(object, member, type, key TSRMLS_CC); } else if ((SUCCESS != zend_hash_find(obj->prophandler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void *) &handler)) || !handler->read) { return_value = zend_get_std_object_handlers()->read_property(object, member, type, key TSRMLS_CC); } else if (type != BP_VAR_R) { - zend_error(E_ERROR, "Cannot access %s properties by reference or array key/index", ancestor(obj->zo.ce)->name); + php_error(E_WARNING, "Cannot access %s properties by reference or array key/index", ancestor(obj->zo.ce)->name); return_value = zend_get_std_object_handlers()->read_property(object, member, type, key TSRMLS_CC); } else { ALLOC_ZVAL(return_value); @@ -137,7 +137,10 @@ void php_pq_object_write_prop(zval *object, zval *member, zval *value, const zen php_pq_object_t *obj = zend_object_store_get_object(object TSRMLS_CC); php_pq_object_prophandler_t *handler; - if (SUCCESS == zend_hash_find(obj->prophandler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void *) &handler)) { + if (!obj->intern) { + php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name); + zend_get_std_object_handlers()->write_property(object, member, value, key TSRMLS_CC); + } else if (SUCCESS == zend_hash_find(obj->prophandler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void *) &handler)) { if (handler->write) { handler->write(object, obj, value TSRMLS_CC); } diff --git a/src/php_pqconn.c b/src/php_pqconn.c index 3b920e7..c4d6c80 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -219,7 +219,7 @@ static void php_pqconn_object_write_encoding(zval *object, void *o, zval *value } if (0 > PQsetClientEncoding(obj->intern->conn, Z_STRVAL_P(zenc))) { - zend_error(E_NOTICE, "Unrecognized encoding '%s'", Z_STRVAL_P(zenc)); + php_error(E_NOTICE, "Unrecognized encoding '%s'", Z_STRVAL_P(zenc)); } if (zenc != value) {