text: Title: `rectangle_perimeter` with NaN params causes fatal memory leak
  Body: ### Description:
  
  Following code raises RAM usage to 100% within a few seconds and hangs the (64GB) machine. I had the NaN's due to an invalid bounding box calculation.
  
  ### Way to reproduce:
  
  ```
  import numpy as np
  from skimage.draw import rectangle_perimeter
  rectangle_perimeter((np.nan, np.nan), (np.nan, np.nan))
  
  ```
  
  ### Version information:
  
  ```Shell
  3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
  Windows-10-10.0.22621-SP0 (I am actually on Windows 11)
  scikit-image version: 0.21.0
  numpy version: 1.24.3
  ```
  