summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2022-12-20 13:26:30 +0100
committerTomas Mraz <tmraz@fedoraproject.org>2022-12-20 13:26:30 +0100
commit4836d8db33615a2f0efd1a1f381872242b0e3192 (patch)
tree080fa86b8259d4ce999e27480f5a8327b199db26
parent5490e96a3dd6ed7371435ca5b3ccef98bdb48b5a (diff)
downloadlibpwquality-git-4836d8db33615a2f0efd1a1f381872242b0e3192.tar.gz
Refactor consecutive check to un-confuse valgrind
Fixes #66
-rw-r--r--src/check.c10
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)