diff options
author | Tomas Mraz <tmraz@fedoraproject.org> | 2022-12-20 13:26:30 +0100 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2022-12-20 13:26:30 +0100 |
commit | 4836d8db33615a2f0efd1a1f381872242b0e3192 (patch) | |
tree | 080fa86b8259d4ce999e27480f5a8327b199db26 | |
parent | 5490e96a3dd6ed7371435ca5b3ccef98bdb48b5a (diff) | |
download | libpwquality-git-4836d8db33615a2f0efd1a1f381872242b0e3192.tar.gz |
Refactor consecutive check to un-confuse valgrind
Fixes #66
-rw-r--r-- | src/check.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/check.c b/src/check.c index 3696d44..d24bebc 100644 --- a/src/check.c +++ b/src/check.c @@ -307,15 +307,15 @@ simple(pwquality_settings_t *pwq, const char *new, void **auxerror) static int consecutive(pwquality_settings_t *pwq, const char *new, void **auxerror) { - char c; + char c = new[0]; int i; - int same; + int same = 1; - if (pwq->max_repeat == 0) + if (pwq->max_repeat == 0 || c == '\0') return 0; - for (i = 0; new[i]; i++) { - if (i > 0 && new[i] == c) { + for (i = 1; new[i]; i++) { + if (new[i] == c) { ++same; if (same > pwq->max_repeat) { if (auxerror) |