fail() should probably be above the setting lines, since that way you know what state the rect was in when you passed it to this function. (I'm assuming fail() does nothing in release?)