There is a possibility that an overflow happens in the equation (int) = (unsigned int) - (unsigned int).
In my PC, 'top_bottom_corner = (480 - 512) / 2' became large positive value and skipped 'if (top_bottom_corner < 0)'. Then It causes segmentation fault. You may want to use explicit casting to avoid that.
There is a possibility that an overflow happens in the equation (int) = (unsigned int) - (unsigned int). In my PC, 'top_bottom_corner = (480 - 512) / 2' became large positive value and skipped 'if (top_bottom_corner < 0)'. Then It causes segmentation fault. You may want to use explicit casting to avoid that.