Prevent Internal Server Error if range is backwards

Fixes redmine #3950 - ip_range_to_subnet_array can easily swap the input parameters if the caller has passed/entered them the wrong way around. That is both friendly to the caller and ensures that a hostile caller can't blow up the routine.
This patch is for master (2.2)
Merge pull request #1313 from phil-davis/patch-9

Prevent Internal Server Error if range is backwards