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.
This commit is contained in:
Andrew Browning 2017-09-20 00:20:43 -04:00
parent 763eae89d9
commit 07c535c876

View File

@ -175,18 +175,14 @@ def get_gps_data(tags):
pass pass
try: try:
gps_data['direction'] = ( direction = tags['GPS GPSImgDirection'].values[0]
lambda d: gps_data['direction'] = safe_gps_ratio_divide(direction)
float(d.num) / float(d.den)
)(tags['GPS GPSImgDirection'].values[0])
except KeyError: except KeyError:
pass pass
try: try:
gps_data['altitude'] = ( altitude = tags['GPS GPSAltitude'].values[0]
lambda a: gps_data['altitude'] = safe_gps_ratio_divide(altitude)
float(a.num) / float(a.den)
)(tags['GPS GPSAltitude'].values[0])
except KeyError: except KeyError:
pass pass