diff --git a/gexiv2/gexiv2-metadata-gps.cpp b/gexiv2/gexiv2-metadata-gps.cpp
index 51f1495..915ebd9 100644
--- a/gexiv2/gexiv2-metadata-gps.cpp
+++ b/gexiv2/gexiv2-metadata-gps.cpp
@@ -41,38 +41,29 @@ gboolean gexiv2_metadata_get_gps_longitude (GExiv2Metadata *self, gdouble *longi
             num = (double)((*it).toRational(0).first);
             den = (double)((*it).toRational(0).second);
 
-            if (den == 0) {
-                g_free(longitude_ref);
-                return FALSE;
+            if (den != 0) {
+                *longitude = num / den;
             }
 
-            *longitude = num / den;
-
             num = (double)((*it).toRational(1).first);
             den = (double)((*it).toRational(1).second);
 
-            if (den == 0) {
-                g_free(longitude_ref);
-                return FALSE;
-            }
-
-            min = num/den;
+            if (den != 0) {
+                min = num/den;
 
-            if (min != -1.0)
-                *longitude = *longitude + min / 60.0;
+                if (min != -1.0)
+                    *longitude = *longitude + min / 60.0;
+            }
 
             num = (double)((*it).toRational(2).first);
             den = (double)((*it).toRational(2).second);
 
-            if (den == 0) {
-                g_free(longitude_ref);
-                return FALSE;
-            }
-
-            sec = num/den;
+            if (den != 0) {
+                sec = num/den;
 
-            if (sec != -1.0)
-                *longitude = *longitude + sec / 3600.0;
+                if (sec != -1.0)
+                    *longitude = *longitude + sec / 3600.0;
+            }
         } else {
             g_free(longitude_ref);
             return FALSE;
@@ -115,38 +106,29 @@ gboolean gexiv2_metadata_get_gps_latitude (GExiv2Metadata *self, gdouble *latitu
             num = (double)((*it).toRational(0).first);
             den = (double)((*it).toRational(0).second);
 
-            if (den == 0) {
-                g_free(latitude_ref);
-                return FALSE;
+            if (den != 0) {
+                *latitude = num / den;
             }
 
-            *latitude = num / den;
-
             num = (double)((*it).toRational(1).first);
             den = (double)((*it).toRational(1).second);
 
-            if (den == 0) {
-                g_free(latitude_ref);
-                return FALSE;
-            }
-
-            min = num/den;
+            if (den != 0) {
+                min = num/den;
 
-            if (min != -1.0)
-                *latitude = *latitude + min / 60.0;
+                if (min != -1.0)
+                    *latitude = *latitude + min / 60.0;
+            }
 
             num = (double)((*it).toRational(2).first);
             den = (double)((*it).toRational(2).second);
 
-            if (den == 0) {
-                g_free(latitude_ref);
-                return FALSE;
-            }
-
-            sec = num/den;
+            if (den != 0) {
+                sec = num/den;
 
-            if (sec != -1.0)
-                *latitude = *latitude + sec / 3600.0;
+                if (sec != -1.0)
+                    *latitude = *latitude + sec / 3600.0;
+            }
         } else {
             g_free(latitude_ref);
             return FALSE;
