|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-22 00:20 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 07:00:01 2025 UTC |
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 {