v_srat = exif_get_srational (
e->data + 8 * i, o);
if (v_srat.denominator) {
- int decimals = (int)(log10(fabs(v_srat.denominator))-0.08+1.0);
+ int decimals = (int)(log10(abs(v_srat.denominator))-0.08+1.0);
snprintf (val+len, maxlen-len, "%2.*f",
decimals,
(double) v_srat.numerator /
{"" , 0, 0}
};
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- if (!e || !e->parent || !e->parent->parent || !maxlen)
+ if (!e || !e->parent || !e->parent->parent || !maxlen || !val)
return val;
/* make sure the returned string is zero terminated */
}
}
if (d)
- snprintf (b, sizeof (b), _(" (35 equivalent: %d mm)"),
- (int) (d * (double) v_rat.numerator /
- (double) v_rat.denominator));
+ snprintf (b, sizeof (b), _(" (35 equivalent: %.0f mm)"),
+ (d * (double) v_rat.numerator /
+ (double) v_rat.denominator));
else
b[0] = 0;
}
d = (double) v_rat.numerator / (double) v_rat.denominator;
if (d < 1)
- snprintf (val, maxlen, _("1/%i"), (int) (0.5 + 1. / d));
+ snprintf (val, maxlen, _("1/%.0f"), 1. / d);
else
- snprintf (val, maxlen, "%i", (int) d);
+ snprintf (val, maxlen, "%.0f", d);
strncat (val, _(" sec."), maxlen-1 - strlen (val));
break;
case EXIF_TAG_SHUTTER_SPEED_VALUE:
snprintf (val, maxlen, _("%.02f EV"), d);
d = 1. / pow (2, d);
if (d < 1)
- snprintf (b, sizeof (b), _(" (1/%d sec.)"), (int) (1. / d));
+ snprintf (b, sizeof (b), _(" (1/%.0f sec.)"), 1. / d);
else
- snprintf (b, sizeof (b), _(" (%d sec.)"), (int) d);
+ snprintf (b, sizeof (b), _(" (%.0f sec.)"), d);
strncat (val, b, maxlen-1 - strlen (val));
break;
case EXIF_TAG_BRIGHTNESS_VALUE:
utf16 = exif_mem_alloc (e->priv->mem, e->size+sizeof(unsigned short));
if (!utf16) break;
memcpy(utf16, e->data, e->size);
+
+ /* NUL terminate the string. If the size is odd (which isn't possible
+ * for a UTF16 string), then this will overwrite the final garbage byte.
+ */
utf16[e->size/sizeof(unsigned short)] = 0;
/* Warning! The texts are converted from UTF16 to UTF8 */