[Rawstudio-commit] r3483 - in trunk: librawstudio plugins/meta-tiff

Klaus Post klauspost at gmail.com
Wed Aug 4 22:11:25 CEST 2010


Author: post
Date: 2010-08-04 22:11:25 +0200 (Wed, 04 Aug 2010)
New Revision: 3483

Modified:
   trunk/librawstudio/rs-rawfile.c
   trunk/plugins/meta-tiff/tiff-meta.c
Log:
Fix uninitilized values, and check values for rational values (Thanks Edouard!)

Modified: trunk/librawstudio/rs-rawfile.c
===================================================================
--- trunk/librawstudio/rs-rawfile.c	2010-08-01 17:41:41 UTC (rev 3482)
+++ trunk/librawstudio/rs-rawfile.c	2010-08-04 20:11:25 UTC (rev 3483)
@@ -149,8 +149,10 @@
 		return(FALSE);
 
 	guint counter, divisor;
-	raw_get_uint(rawfile, pos, &counter);
-	raw_get_uint(rawfile, pos+4, &divisor);
+	if (!raw_get_uint(rawfile, pos, &counter))
+		return FALSE;
+	if (!raw_get_uint(rawfile, pos+4, &divisor))
+		return FALSE;
 
 	if (divisor == 0)
 		return(FALSE);

Modified: trunk/plugins/meta-tiff/tiff-meta.c
===================================================================
--- trunk/plugins/meta-tiff/tiff-meta.c	2010-08-01 17:41:41 UTC (rev 3482)
+++ trunk/plugins/meta-tiff/tiff-meta.c	2010-08-04 20:11:25 UTC (rev 3483)
@@ -109,9 +109,13 @@
 get_rational(RAWFILE *rawfile, guint offset)
 {
 	guint uint1=0, uint2=1;
-	raw_get_uint(rawfile, offset, &uint1);
-	raw_get_uint(rawfile, offset+4, &uint2);
+	if (!raw_get_uint(rawfile, offset, &uint1))
+		return 0;
+	if (!raw_get_uint(rawfile, offset+4, &uint2))
+		return 0;
 
+	if (uint2 == 0)
+		return 0;
 	return ((gdouble) uint1) / ((gdouble) uint2);
 }
 
@@ -119,7 +123,6 @@
 read_ifd(RAWFILE *rawfile, guint offset, struct IFD *ifd)
 {
 /*	guint size = 0; */
-	guint uint1, uint2;
 
 	raw_get_ushort(rawfile, offset, &ifd->tag);
 	raw_get_ushort(rawfile, offset+2, &ifd->type);
@@ -152,10 +155,9 @@
 				ifd->value = ifd->value_uint;
 				break;
 			case TIFF_FIELD_TYPE_RATIONAL:
-				raw_get_uint(rawfile, ifd->value_offset, &uint1);
-				raw_get_uint(rawfile, ifd->value_offset+4, &uint2);
-				ifd->value_rational = ((gdouble) uint1) / ((gdouble) uint2);
+				ifd->value_rational = get_rational(rawfile,  ifd->value_offset);
 				ifd->value = ifd->value_rational;
+				break;
 			default:
 				/* FIXME: Implement types from TIFF 6.0 */
 				break;




More information about the Rawstudio-commit mailing list