summaryrefslogtreecommitdiff
blob: 2a5fc03b5a7c851ea5b20d1cd7cfb570fc3ce1c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- libtiff/tif_dirread.c.orig	2005-05-08 10:28:15.000000000 -0700
+++ libtiff/tif_dirread.c	2005-05-08 10:45:26.000000000 -0700
@@ -1310,12 +1310,15 @@
 		uint16 buf[10];
 		uint16* v = buf;
 
-		if (samples > NITEMS(buf))
-			v = (uint16*) CheckMalloc(tif, samples, sizeof(uint16),
+		if (dir->tdir_count > NITEMS(buf))
+			v = (uint16*) CheckMalloc(tif, dir->tdir_count, sizeof(uint16),
 						  "to fetch per-sample values");
 		if (v && TIFFFetchShortArray(tif, dir, v)) {
 			uint16 i;
-			for (i = 1; i < samples; i++)
+			int check_count = dir->tdir_count;
+			if( samples < check_count )
+				check_count = samples;
+			for (i = 1; i < check_count; i++)
 				if (v[i] != v[0]) {
 					TIFFError(tif->tif_name,
 		"Cannot handle different per-sample values for field \"%s\"",
@@ -1347,12 +1350,15 @@
 		uint32 buf[10];
 		uint32* v = buf;
 
-		if (samples > NITEMS(buf))
-			v = (uint32*) CheckMalloc(tif, samples, sizeof(uint32),
+		if (dir->tdir_count > NITEMS(buf))
+			v = (uint32*) CheckMalloc(tif, dir->tdir_count, sizeof(uint32),
 						  "to fetch per-sample values");
 		if (v && TIFFFetchLongArray(tif, dir, v)) {
 			uint16 i;
-			for (i = 1; i < samples; i++)
+			int check_count = dir->tdir_count;
+			if( samples < check_count )
+				check_count = samples;
+			for (i = 1; i < check_count; i++)
 				if (v[i] != v[0]) {
 					TIFFError(tif->tif_name,
 		"Cannot handle different per-sample values for field \"%s\"",
@@ -1384,12 +1390,15 @@
 		double buf[10];
 		double* v = buf;
 
-		if (samples > NITEMS(buf))
-			v = (double*) CheckMalloc(tif, samples, sizeof (double),
+		if (dir->tdir_count > NITEMS(buf))
+			v = (double*) CheckMalloc(tif, dir->tdir_count, sizeof (double),
 						  "to fetch per-sample values");
 		if (v && TIFFFetchAnyArray(tif, dir, v)) {
 			uint16 i;
-			for (i = 1; i < samples; i++)
+			int check_count = dir->tdir_count;
+			if( samples < check_count )
+				check_count = samples;
+			for (i = 1; i < check_count; i++)
 				if (v[i] != v[0]) {
 					TIFFError(tif->tif_name,
 		"Cannot handle different per-sample values for field \"%s\"",