Fix possible out-of-bound array access in GMapsGeocoder::getTextToGeocode
[platal.git] / classes / gmapsgeocoder.php
index bea3a52..e009080 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2013 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -241,6 +241,9 @@ class GMapsGeocoder extends Geocoder {
         }
         $textLines  = explode("\n", $text);
         $countLines = count($textLines);
+        if ($countLines < 2) {
+            return $text;
+        }
         $needle     = strtoupper(trim($textLines[$countLines - 2]));
         $isPseudoCountry = false;
         if ($needle) {
@@ -259,5 +262,5 @@ class GMapsGeocoder extends Geocoder {
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>