diff --git a/src/sapB_fmt_plug.c b/src/sapB_fmt_plug.c index 6a906b0d74..c10e9a9494 100644 --- a/src/sapB_fmt_plug.c +++ b/src/sapB_fmt_plug.c @@ -661,7 +661,7 @@ static int crypt_all(int *pcount, struct db_salt *salt) keyLen[t] = strlen(saved_plain[t]); // Back-out of trailing spaces - while ( saved_plain[t][keyLen[t] - 1] == ' ' ) + while ( keyLen[t] && saved_plain[t][keyLen[t] - 1] == ' ' ) { if (keyLen[t] == 0) break; saved_plain[t][--keyLen[t]] = 0; diff --git a/src/sapG_fmt_plug.c b/src/sapG_fmt_plug.c index 72a0ce6ac2..e282d25dd0 100644 --- a/src/sapG_fmt_plug.c +++ b/src/sapG_fmt_plug.c @@ -666,7 +666,7 @@ static int crypt_all(int *pcount, struct db_salt *salt) keyLen[index] = strlen((char*)saved_key[index]); // Back-out of trailing spaces - while (saved_key[index][keyLen[index] - 1] == ' ') { + while (keyLen[index] && saved_key[index][keyLen[index] - 1] == ' ') { saved_key[index][--keyLen[index]] = 0; if (keyLen[index] == 0) break; }