It seems like this would throw if filter == 0. While that would be an odd thing to pass, I could see it arising from some poorly thought out client logic, so perhaps it'd be best to play nicely in that case.