Lacking exception handling in Synchronize translation (i18nsync) module

One thing that many contrib modules for Drupal lack is proper exception handling. One issue in particular that I've come across time and again is the neglect of checking that a variable is an array before looping through it in a foreach clause, which produces an easily avoidable error. The latest example of this issues appeared in the "Synchronize translations" module (i18nsync), which is part of the Internationalization module (i18n). It was synchronizing an image between a Swedish node and its English version when this foreach error appeared. What you need to do in order to solve this particular problem is to enter i18nsync.module, find the function "i18nsync_node_translation_filefield_field" and change this:

foreach ($translation->$field as $translation_image) {
  if ($file['fid'] == $translation_image['fid']) {
    $translated_images[] = $translation_image;
    $found = true;
    if(function_exists('i18sync_improvements_spread_file')) i18sync_improvements_spread_file($file);
  }
}

to this:

if(is_array($translation->$field)) {
  foreach ($translation->$field as $translation_image) {
    if ($file['fid'] == $translation_image['fid']) {
      $translated_images[] = $translation_image;
      $found = true;
      if(function_exists('i18sync_improvements_spread_file')) i18sync_improvements_spread_file($file);
    }
  }
}

I've made a patch for this particular example (although there are many more in this module alone) which you can find at http://drupal.org/node/1461270#comment-5668694.