2
0

Some more error handling.

This commit is contained in:
Maarten Billemont
2017-08-01 17:13:30 -04:00
parent 99e286456e
commit b00ad53e42
4 changed files with 15 additions and 9 deletions

View File

@@ -26,13 +26,12 @@
#define MP_N 32768
#define MP_r 8
#define MP_p 2
#define MP_hash PearlHashSHA256
static const char *mpw_templateForType_v0(MPPasswordType type, uint16_t seedByte) {
size_t count = 0;
const char **templates = mpw_templatesForType( type, &count );
char const *template = count? templates[seedByte % count]: NULL;
char const *template = templates && count? templates[seedByte % count]: NULL;
free( templates );
return template;
}

View File

@@ -150,7 +150,7 @@ const char *mpw_templateForType(MPPasswordType type, uint8_t seedByte) {
size_t count = 0;
const char **templates = mpw_templatesForType( type, &count );
char const *template = count? templates[seedByte % count]: NULL;
char const *template = templates && count? templates[seedByte % count]: NULL;
free( templates );
return template;
}