Fix #5524 Zero division error in exif.py
authorAndrew Browning <ayleph@thisshitistemp.com>
Wed, 20 Sep 2017 04:20:43 +0000 (00:20 -0400)
committerAndrew Browning <ayleph@thisshitistemp.com>
Wed, 20 Sep 2017 04:22:19 +0000 (00:22 -0400)
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.

mediagoblin/tools/exif.py

index fafd987d167680e267b893ab663edd7aa75f23d8..a428ddf105c1dc37ad5ff630371c8fac828d3c60 100644 (file)
@@ -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