DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.09k stars 1.47k forks source link

Handle undefined callbacks in setters on iOS native module #1015

Open onurersel opened 7 months ago

onurersel commented 7 months ago

Sequence of events that ends up with crash are:

  1. Set one of the callback with a function (ie. onError)
  2. Try to load an invalid image, that will result with onError callback being called.
  3. Set onError callback to undefined.

At this point, native iOS module tries to call the undefined function, which crashes the app with EXT_BAD_ACCESS.

This PR updates all setter functions and checks if the callback function exists before calling them.