ID: 43041 Updated by: [EMAIL PROTECTED] Reported By: andy at petdance dot com -Status: Open +Status: Closed Bug Type: PostgreSQL related Operating System: * PHP Version: 5.2.4 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-10-19 15:19:46] andy at petdance dot com Description: ------------ Not a bug at all. Just was looking at the code for the Postgres fetching, and there are a couple of places where it's redundantly checking for NULLness on a pointer. This patch fixes it. Reproduce code: --------------- --- ext/pgsql/pgsql-old.c 2007-10-19 10:03:42.166485760 -0500 +++ ext/pgsql/pgsql.c 2007-10-19 10:08:29.289836376 -0500 @@ -1992,7 +1992,6 @@ int i, num_fields, pgsql_row, use_row; long row = -1; char *element, *field_name; - uint element_len; zval *ctor_params = NULL; zend_class_entry *ce = NULL; @@ -2064,11 +2063,11 @@ } } else { element = PQgetvalue(pgsql_result, pgsql_row, i); - element_len = (element ? strlen(element) : 0); if (element) { char *data; int data_len; int should_copy=0; + const uint element_len = strlen(element); if (PG(magic_quotes_runtime)) { data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); @@ -5712,7 +5711,7 @@ { zval *row; char *field_name, *element, *data; - size_t num_fields, element_len, data_len; + size_t num_fields; int pg_numrows, pg_row; uint i; assert(Z_TYPE_P(ret_array) == IS_ARRAY); @@ -5730,8 +5729,9 @@ add_assoc_null(row, field_name); } else { element = PQgetvalue(pg_result, pg_row, i); - element_len = (element ? strlen(element) : 0); if (element) { + const size_t element_len = strlen(element); + size_t data_len; if (PG(magic_quotes_runtime)) { data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); } else { ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43041&edit=1
