[folks] PotentialMatch: fix end-of-string check, part 2.



commit eaaa6fac6ec7d143148cbe9b8f78fe569d4fef4e
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Jan 6 13:11:03 2018 +0100

    PotentialMatch: fix end-of-string check, part 2.
    
    Does the same thing as the previous commit, but now also for the first
    string.
    
    Again fixes bug 7922238 (https://bugzilla.gnome.org/show_bug.cgi?id=792238).

 folks/potential-match.vala |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/folks/potential-match.vala b/folks/potential-match.vala
index 437381d..9e21407 100644
--- a/folks/potential-match.vala
+++ b/folks/potential-match.vala
@@ -633,10 +633,11 @@ public class Folks.PotentialMatch : Object
     {
       int matches = 0;
       t = 0.0;
+      var len_s1 = s1.length;
 
       unichar look_for = 0;
 
-      for (uint idx = 0; (look_for = s1[idx]) != 0; idx++)
+      for (uint idx = 0; idx < len_s1 && (look_for = s1[idx]) != 0; idx++)
         {
           int contains = this._contains (s2, look_for, idx, max_dist);
           if (contains >= 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]