[folks] PotentialMatch: fix end-of-string check.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] PotentialMatch: fix end-of-string check.
- Date: Fri, 5 Jan 2018 13:01:19 +0000 (UTC)
commit 9c4e87e5273f241e45d8bb93369b10903dffeb58
Author: Niels De Graef <nielsdegraef gmail com>
Date: Fri Jan 5 12:22:33 2018 +0100
PotentialMatch: fix end-of-string check.
Since we're not dealing with a `\0`-terminated string anymore, we can't
rely on that to check the end of the string. Add a comparison with the
length instead.
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 f30f743..437381d 100644
--- a/folks/potential-match.vala
+++ b/folks/potential-match.vala
@@ -671,7 +671,8 @@ public class Folks.PotentialMatch : Object
uint idx = ((int) pos - (int) max_dist).clamp (0, haystack_len - 1);
unichar ch = 0;
- while (idx < pos + max_dist && (ch = haystack[idx]) != 0)
+ while (idx < pos + max_dist && idx < haystack_len &&
+ (ch = haystack[idx]) != 0)
{
if (ch == c)
return ((int) pos - (int) idx).abs ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]