[gegl] libs/rgbe: Always reset errno before using it
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] libs/rgbe: Always reset errno before using it
- Date: Sat, 7 Aug 2010 11:00:38 +0000 (UTC)
commit 4894f0405081efae7fe9aec60d3b5bad7fd67e69
Author: Martin Nordholts <martinn src gnome org>
Date: Sat Aug 7 12:57:45 2010 +0200
libs/rgbe: Always reset errno before using it
Always reset errno before relying on it to ensure success in a
call. It might have been set by some other call previously, for
example a g_dgettext() call for a translation file that does not
exist.
libs/rgbe/rgbe.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libs/rgbe/rgbe.c b/libs/rgbe/rgbe.c
index 02e1272..0bdc5b7 100644
--- a/libs/rgbe/rgbe.c
+++ b/libs/rgbe/rgbe.c
@@ -245,9 +245,10 @@ rgbe_header_read_variables (rgbe_file *file,
{
gdouble exposure;
- data += strlen ("EXPOSURE=");
- exposure = g_ascii_strtod (data, NULL);
+ data += strlen ("EXPOSURE=");
+ errno = 0;
+ exposure = g_ascii_strtod (data, NULL);
if (errno)
{
g_warning ("Invalid value for exposure in radiance image file");
@@ -267,7 +268,10 @@ rgbe_header_read_variables (rgbe_file *file,
for (i = 0; i < RGBE_NUM_RGB; ++i)
{
- gdouble multiplier = g_ascii_strtod (data, (gchar**)&data);
+ gdouble multiplier;
+
+ errno = 0;
+ multiplier = g_ascii_strtod (data, (gchar**)&data);
if (errno)
{
g_warning ("Invalid value for COLORCORR");
@@ -308,8 +312,9 @@ rgbe_header_read_variables (rgbe_file *file,
gdouble aspect;
data += strlen ("PIXASPECT=");
- aspect = g_ascii_strtod (data, (gchar **)&data);
+ errno = 0;
+ aspect = g_ascii_strtod (data, (gchar **)&data);
if (errno)
{
g_warning ("Invalid pixel aspect ratio");
@@ -429,6 +434,7 @@ rgbe_header_read_orientation (rgbe_file *file,
if (*data++ != ' ')
goto cleanup;
+ errno = 0;
axis->size = g_ascii_strtoull (data, (gchar **)&data, 0);
if (errno)
goto cleanup;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]