Esme Povirk (@madewokherd) commented about dlls/sane.ds/ds_image.c:
+ if (y < -header->biHeight && y>0) + { + /* Data source sent less data than allocated. + * This is common when using an ADF. + * Reduce the DIB to the size that has actually been transfered. */ + GlobalUnlock(hDIB); + + dib_bytes += y * dib_bytes_per_line; + hDIB = GlobalReAlloc(hDIB, dib_bytes + sizeof(*header) + color_size, GMEM_MOVEABLE); + + if (!hDIB) + { + SANE_Cancel(); + activeDS.twCC = TWCC_LOWMEMORY; + activeDS.currentState = 6; + return TWRC_FAILURE; hDIB needs to be freed in this case.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9397#note_121536