Skip to content

Commit

Permalink
Fix overflow akward implementation
Browse files Browse the repository at this point in the history
Issue #55
  • Loading branch information
mellowcandle committed Jul 18, 2023
1 parent e05fb0d commit 77f8f45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ static int parse_cmd(char *cmdline)
return -1;
} else {
char result_string[256];
if (result > MASK(g_width)) {
result &= MASK(g_width);
append_to_history("Overflow!", TYPE_OUTPUT_ERROR);
}
g_val = result;

if (g_output == CMD_OUTPUT_ALL) {
Expand Down
3 changes: 1 addition & 2 deletions src/interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void process_fields(int ch)
wrefresh(fields_win);
break;
default:
LOG("default char\n");
LOG("default char: %d\n", ch);

tmp_field = current_field(form);
cur_base = field_userptr(tmp_field);
Expand Down Expand Up @@ -651,7 +651,6 @@ int start_interactive(uint64_t start)
}
break;


case KEY_F(1):
unpaint_screen();
show_help();
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ int main(int argc, char *argv[])
free(expression);
if (!g_width)
set_width_by_val(val);
if (val > MASK(g_width))
fprintf(stderr, "%sExpression overflowed!\n", color_red);
val &= MASK(g_width);
if (!interactive)
return print_conversions(val, si);
Expand Down

0 comments on commit 77f8f45

Please sign in to comment.