From: Andrew Browning Date: Wed, 20 Sep 2017 04:20:43 +0000 (-0400) Subject: Fix #5524 Zero division error in exif.py X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=07c535c;p=mediagoblin.git Fix #5524 Zero division error in exif.py This patch implements the safe_gps_ratio_divide function for gps direction and altitude values to prevent a zero divide error on malformed GPS data. --- diff --git a/mediagoblin/tools/exif.py b/mediagoblin/tools/exif.py index fafd987d..a428ddf1 100644 --- a/mediagoblin/tools/exif.py +++ b/mediagoblin/tools/exif.py @@ -175,18 +175,14 @@ def get_gps_data(tags): pass try: - gps_data['direction'] = ( - lambda d: - float(d.num) / float(d.den) - )(tags['GPS GPSImgDirection'].values[0]) + direction = tags['GPS GPSImgDirection'].values[0] + gps_data['direction'] = safe_gps_ratio_divide(direction) except KeyError: pass try: - gps_data['altitude'] = ( - lambda a: - float(a.num) / float(a.den) - )(tags['GPS GPSAltitude'].values[0]) + altitude = tags['GPS GPSAltitude'].values[0] + gps_data['altitude'] = safe_gps_ratio_divide(altitude) except KeyError: pass