Skip to content

Commit 75c7cd4

Browse files
committed
Cracker: Bugfix for 2nd self-test that may occur in debug builds
Like the normal self-test, we need to initialize a test_db to use for it. I came up with this patch 2.5 years ago but then forgot all about it. Closes #5295
1 parent e592fe2 commit 75c7cd4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/cracker.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,15 @@ void crk_init(struct db_main *db, void (*fix_state)(void),
182182
* or if the format has a custom reset() method (we've already called reset(db)
183183
* from john.c, and we don't want to mess with the format's state).
184184
*/
185-
if (db->loaded && db->format->methods.reset == fmt_default_reset)
186-
if ((where = fmt_self_test(db->format, db))) {
187-
log_event("! Self test failed (%s)", where);
188-
fprintf(stderr, "Self test failed (%s)\n", where);
189-
error();
185+
if (db->loaded && db->format->methods.reset == fmt_default_reset && !(options.flags & FLG_NOTESTS)) {
186+
struct db_main *test_db = ldr_init_test_db(db->format, db);
187+
188+
if ((where = fmt_self_test(db->format, test_db))) {
189+
log_event("! Self test failed (%s)", where);
190+
fprintf(stderr, "Self test failed (%s)\n", where);
191+
error();
192+
}
193+
ldr_free_db(test_db, 1);
190194
}
191195

192196
#if HAVE_OPENCL

0 commit comments

Comments
 (0)