On Wed Sep 3 20:08:30 2025 +0000, Ivan Lyugaev wrote:
This block repeats the initialization of the parameters in the InitializeDialog function. I have saved only the necessary operations to generate the parameters. ` else if (opt.type == TYPE_FIXED) { int pos, min, max, *sf; if (opt.constraint.range.quant) { min = opt.constraint.range.min / opt.constraint.range.quant; max = opt.constraint.range.max / opt.constraint.range.quant; } else { min = MulDiv( opt.constraint.range.min, 100, 65536 ); max = MulDiv( opt.constraint.range.max, 100, 65536 ); } SendMessageA(control,SBM_SETRANGE,min,max); sf = calloc( opt.size, sizeof(int) ); sane_option_get_value( i, sf ); /* Note that conversion of float -> SANE_Fixed is lossy; * and when you truncate it into an integer, you can get * unfortunate results. This calculation attempts * to mitigate that harm */ if (opt.constraint.range.quant) pos = *sf / opt.constraint.range.quant; else pos = MulDiv( *sf, 100, 65536 ); free(sf); SendMessageW(control, SBM_SETPOS, pos, TRUE); UpdateRelevantEdit(hwnd, &opt, pos); } `
If a case isn't covered in InitializeDialog, the value just isn't set in the UI. If a case isn't covered here, undefined memory is used.