[tracker] libtracker-extract: Do some basic checks for GPS coordinates in EXIF tags
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-extract: Do some basic checks for GPS coordinates in EXIF tags
- Date: Fri, 24 Jun 2011 15:20:06 +0000 (UTC)
commit 4b319b8ed06066a69feaf314c9c1cec582beb241
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Jun 24 17:14:38 2011 +0200
libtracker-extract: Do some basic checks for GPS coordinates in EXIF tags
On some photos it would get the ExifEntries, but the coordinates wouldn't
be meaningful, so at least check the rational numbers' denominators to
avoid division by zero.
src/libtracker-extract/tracker-exif.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-exif.c b/src/libtracker-extract/tracker-exif.c
index 37fd810..280621e 100644
--- a/src/libtracker-extract/tracker-exif.c
+++ b/src/libtracker-extract/tracker-exif.c
@@ -297,7 +297,14 @@ get_gps_coordinate (ExifData *exif,
c2 = exif_get_rational (entry->data+8, order);
c3 = exif_get_rational (entry->data+16, order);
ref = exif_get_short (refentry->data, order);
-
+
+ /* Avoid ridiculous values */
+ if (c1.denominator == 0 ||
+ c2.denominator == 0 ||
+ c3.denominator == 0) {
+ return NULL;
+ }
+
f = (double)c1.numerator/c1.denominator+
(double)c2.numerator/(c2.denominator*60)+
(double)c3.numerator/(c3.denominator*60*60);
@@ -327,6 +334,12 @@ get_gps_altitude (ExifData *exif,
order = exif_data_get_byte_order (exif);
c = exif_get_rational (entry->data, order);
+
+ /* Avoid ridiculous values */
+ if (c.denominator == 0) {
+ return NULL;
+ }
+
f = (double)c.numerator/c.denominator;
/* Strictly speaking it is invalid not to have this
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]