Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:set line_w bounds check #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion xpaint.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,12 @@ ClCPrcResult cl_cmd_process(struct Ctx* ctx, struct ClCommand const* cl_cmd) {
case ClC_Set: {
switch (cl_cmd->d.set.t) {
case ClCDS_LineW: {
CURR_TC(ctx).sdata.line_w = cl_cmd->d.set.d.line_w.value;
u32 val = cl_cmd->d.set.d.line_w.value;
if(val < 1) {
msg_to_show = str_new("line_w must be 1 or greater, using default");
val = TOOLS.default_line_w;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to only show the message on error. It will be clearer for the user

}
CURR_TC(ctx).sdata.line_w = val;
} break;
case ClCDS_Col: {
*tc_curr_col(&CURR_TC(ctx)) = cl_cmd->d.set.d.col.v;
Expand Down