Fix some bugs in DIB mapping code to prevent instant system crashes.