From 08201e11fe07b5f1e83b08aa2ef8f0e130fdc72c Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 17 Sep 2011 03:12:23 +0000 Subject: [PATCH] Fix Bug #55703(PHP crash when calling mysqli_fetch_fields) Since the catalog values always is "def" now, see http://dev.mysql.com/doc/refman/5.0/en/c-api-data-structures.html --- ext/mysqli/mysqli_api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index e102a7cef49..096f86d138a 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1053,7 +1053,12 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML add_property_string(value, "orgtable", (char *) (field->org_table ? field->org_table : ""), 1); add_property_string(value, "def", (field->def ? field->def : ""), 1); add_property_string(value, "db", (field->db ? field->db : ""), 1); - add_property_string(value, "catalog", (field->catalog ? field->catalog : ""), 1); + + /* FIXME: manually set the catalog to "def" due to bug in + * libmysqlclient which does not initialize field->catalog + * and in addition, the catalog is always be "def" + */ + add_property_string(value, "catalog", "def", 1); add_property_long(value, "max_length", field->max_length); add_property_long(value, "length", field->length);