php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #68277
Patch patch-geoip-open-type revision 2014-10-23 15:22 UTC by phpbugs at joern dot heissler dot de
Patch geoip-1.1.0-city.patch revision 2014-10-23 13:08 UTC by slim at inbox dot lv
Patch patch-geoip_record_by_name revision 2014-10-23 02:47 UTC by phpbugs at joern dot heissler dot de

Patch patch-geoip_record_by_name for geoip Bug #68277

Patch version 2014-10-23 02:47 UTC

Return to Bug #68277 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: phpbugs@joern.heissler.de

--- php-geoip-1.1.0.orig/geoip-1.1.0/geoip.c
+++ php-geoip-1.1.0/geoip-1.1.0/geoip.c
@@ -538,7 +538,7 @@ PHP_FUNCTION(geoip_netspeedcell_by_name)
    Returns the detailed City information found in the GeoIP Database */
 PHP_FUNCTION(geoip_record_by_name)
 {
-   GeoIP * gi;
+   GeoIP * gi = NULL;
    char * hostname = NULL;
    int arglen;
    GeoIPRecord * gir;
@@ -547,13 +547,13 @@ PHP_FUNCTION(geoip_record_by_name)
        return;
    }

-   if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1) || GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) {
-       if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) {
-           gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD);
-       } else {
-           gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD);
-       }
-   }   else {
+    if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) {
+        gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD);
+    }
+    if (! gi && GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) {
+        gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD);
+    }
+    if (! gi) {
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]);
        return;
    }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 13:01:31 2024 UTC