mirror of
https://codeberg.org/scip/diceware.git
synced 2025-12-16 18:30:58 +01:00
fixed malloc bug
This commit is contained in:
@@ -26,6 +26,7 @@ int *incr_dicedigit(int *digits) {
|
|||||||
increment an array of dice digits, we expect the first to
|
increment an array of dice digits, we expect the first to
|
||||||
be a multiple of 10000, the 2nd a multiple of 1000 and so on.
|
be a multiple of 10000, the 2nd a multiple of 1000 and so on.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(digits[4] == 6) {
|
if(digits[4] == 6) {
|
||||||
digits[4] = 1;
|
digits[4] = 1;
|
||||||
if(digits[3] == 60) {
|
if(digits[3] == 60) {
|
||||||
@@ -87,7 +88,7 @@ char **fetch_dict(char *dictfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
words = malloc(66666 * sizeof(char *));
|
words = malloc(66666 * sizeof(char *));
|
||||||
digits = malloc(5);
|
digits = malloc(5 * sizeof(int));
|
||||||
jump = rand_lim(32);
|
jump = rand_lim(32);
|
||||||
|
|
||||||
digits[0] = 10000;
|
digits[0] = 10000;
|
||||||
@@ -126,12 +127,12 @@ char **fetch_dict(char *dictfile) {
|
|||||||
next = 0;
|
next = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
words[pos] = malloc(linelen);
|
words[pos] = malloc(linelen);
|
||||||
strncpy( words[pos], line, linelen);
|
strncpy( words[pos], line, linelen);
|
||||||
if(verbose > 1)
|
if(verbose > 1)
|
||||||
debug("add to wordlist at index %d: %s", pos, line);
|
debug("add to wordlist at index %d: %s", pos, line);
|
||||||
|
|
||||||
digits = incr_dicedigit(digits);
|
digits = incr_dicedigit(digits);
|
||||||
pos = get_dicenum(digits);
|
pos = get_dicenum(digits);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user