Skip to content

Commit 00393a3

Browse files
committed
1 parent 60d558e commit 00393a3

30 files changed

+431
-431
lines changed

frmts/gtiff/libtiff/tif_aux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int TIFFDefaultTransferFunction(TIFF *tif, TIFFDirectory *td)
138138
return 0;
139139

140140
n = ((tmsize_t)1) << td->td_bitspersample;
141-
nbytes = n * sizeof(uint16_t);
141+
nbytes = (tmsize_t)((uint64_t)n * sizeof(uint16_t));
142142
tf[0] = (uint16_t *)_TIFFmallocExt(tif, nbytes);
143143
if (tf[0] == NULL)
144144
return 0;
@@ -258,8 +258,8 @@ int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap)
258258
* 65535 even if td_bitspersamle is > 16 */
259259
if (td->td_bitspersample <= 16)
260260
{
261-
maxsamplevalue = (1 << td->td_bitspersample) -
262-
1; /* 2**(BitsPerSample) - 1 */
261+
maxsamplevalue = (uint16_t)((1 << td->td_bitspersample) -
262+
1); /* 2**(BitsPerSample) - 1 */
263263
}
264264
else
265265
{
@@ -295,7 +295,7 @@ int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap)
295295
}
296296
case TIFFTAG_DOTRANGE:
297297
*va_arg(ap, uint16_t *) = 0;
298-
*va_arg(ap, uint16_t *) = (1 << td->td_bitspersample) - 1;
298+
*va_arg(ap, uint16_t *) = (uint16_t)((1 << td->td_bitspersample) - 1);
299299
return (1);
300300
case TIFFTAG_INKSET:
301301
*va_arg(ap, uint16_t *) = INKSET_CMYK;

frmts/gtiff/libtiff/tif_color.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,30 @@ int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
145145
/* Red */
146146
dfGamma = 1.0 / cielab->display.d_gammaR;
147147
cielab->rstep =
148-
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
148+
(float)(cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
149149
for (i = 0; i <= (size_t)cielab->range; i++)
150150
{
151-
cielab->Yr2r[i] = cielab->display.d_Vrwr *
151+
cielab->Yr2r[i] = (float)cielab->display.d_Vrwr *
152152
((float)pow((double)i / cielab->range, dfGamma));
153153
}
154154

155155
/* Green */
156156
dfGamma = 1.0 / cielab->display.d_gammaG;
157157
cielab->gstep =
158-
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
158+
(float)(cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
159159
for (i = 0; i <= (size_t)cielab->range; i++)
160160
{
161-
cielab->Yg2g[i] = cielab->display.d_Vrwg *
161+
cielab->Yg2g[i] = (float)cielab->display.d_Vrwg *
162162
((float)pow((double)i / cielab->range, dfGamma));
163163
}
164164

165165
/* Blue */
166166
dfGamma = 1.0 / cielab->display.d_gammaB;
167167
cielab->bstep =
168-
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
168+
(float)(cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
169169
for (i = 0; i <= (size_t)cielab->range; i++)
170170
{
171-
cielab->Yb2b[i] = cielab->display.d_Vrwb *
171+
cielab->Yb2b[i] = (float)cielab->display.d_Vrwb *
172172
((float)pow((double)i / cielab->range, dfGamma));
173173
}
174174

@@ -189,7 +189,7 @@ int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
189189
#define FIX(x) ((int32_t)((x) * (1L << SHIFT) + 0.5))
190190
#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
191191
#define Code2V(c, RB, RW, CR) \
192-
((((c) - (int32_t)(RB)) * (float)(CR)) / \
192+
(((float)((c) - (int32_t)(RB)) * (float)(CR)) / \
193193
(float)(((RW) - (RB) != 0) ? ((RW) - (RB)) : 1))
194194
/* !((f)>=(min)) written that way to deal with NaN */
195195
#define CLAMP(f, min, max) \
@@ -207,12 +207,12 @@ void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr,
207207
Cr = CLAMP(Cr, 0, 255);
208208

209209
i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
210-
*r = CLAMP(i, 0, 255);
210+
*r = (uint32_t)CLAMP(i, 0, 255);
211211
i = ycbcr->Y_tab[Y] +
212212
(int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
213-
*g = CLAMP(i, 0, 255);
213+
*g = (uint32_t)CLAMP(i, 0, 255);
214214
i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
215-
*b = CLAMP(i, 0, 255);
215+
*b = (uint32_t)CLAMP(i, 0, 255);
216216
}
217217

218218
/* Clamp function for sanitization purposes. Normally clamping should not */

frmts/gtiff/libtiff/tif_compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ TIFFCodec *TIFFGetConfiguredCODECs(void)
271271
for (cd = registeredCODECS; cd; cd = cd->next)
272272
{
273273
new_codecs =
274-
(TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec));
274+
(TIFFCodec *)_TIFFreallocExt(NULL, codecs, (tmsize_t)((size_t)i * sizeof(TIFFCodec)));
275275
if (!new_codecs)
276276
{
277277
_TIFFfreeExt(NULL, codecs);
@@ -286,7 +286,7 @@ TIFFCodec *TIFFGetConfiguredCODECs(void)
286286
if (TIFFIsCODECConfigured(c->scheme))
287287
{
288288
new_codecs = (TIFFCodec *)_TIFFreallocExt(NULL, codecs,
289-
i * sizeof(TIFFCodec));
289+
(tmsize_t)((size_t)i * sizeof(TIFFCodec)));
290290
if (!new_codecs)
291291
{
292292
_TIFFfreeExt(NULL, codecs);
@@ -299,7 +299,7 @@ TIFFCodec *TIFFGetConfiguredCODECs(void)
299299
}
300300

301301
new_codecs =
302-
(TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec));
302+
(TIFFCodec *)_TIFFreallocExt(NULL, codecs, (tmsize_t)((size_t)i * sizeof(TIFFCodec)));
303303
if (!new_codecs)
304304
{
305305
_TIFFfreeExt(NULL, codecs);

frmts/gtiff/libtiff/tif_dir.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb,
5050
}
5151
if (vp)
5252
{
53-
tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
53+
tmsize_t bytes = _TIFFMultiplySSize(NULL, (tmsize_t)nmemb, (tmsize_t)elem_size, NULL);
5454
if (bytes)
5555
*vpp = (void *)_TIFFmallocExt(tif, bytes);
5656
if (*vpp)
@@ -121,7 +121,7 @@ static void setDoubleArrayOneValue(TIFF *tif, double **vpp, double value,
121121
{
122122
if (*vpp)
123123
_TIFFfreeExt(tif, *vpp);
124-
*vpp = (double *)_TIFFmallocExt(tif, nmemb * sizeof(double));
124+
*vpp = (double *)_TIFFmallocExt(tif, (tmsize_t)nmemb * (tmsize_t)sizeof(double));
125125
if (*vpp)
126126
{
127127
while (nmemb--)
@@ -294,7 +294,7 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
294294
/*
295295
* Setup new compression routine state.
296296
*/
297-
if ((status = TIFFSetCompressionScheme(tif, v)) != 0)
297+
if ((status = TIFFSetCompressionScheme(tif, (int)v)) != 0)
298298
td->td_compression = (uint16_t)v;
299299
else
300300
status = 0;
@@ -579,7 +579,7 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
579579
if (ninksinstring > 0)
580580
{
581581
_TIFFsetNString(tif, &td->td_inknames, s, v);
582-
td->td_inknameslen = v;
582+
td->td_inknameslen = (int)v;
583583
/* Set NumberOfInks to the value ninksinstring */
584584
if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
585585
{
@@ -725,7 +725,7 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
725725

726726
new_customValues = (TIFFTagValue *)_TIFFreallocExt(
727727
tif, td->td_customValues,
728-
sizeof(TIFFTagValue) * (td->td_customValueCount + 1));
728+
(tmsize_t)(sizeof(TIFFTagValue) * (size_t)(td->td_customValueCount + 1)));
729729
if (!new_customValues)
730730
{
731731
TIFFErrorExtR(tif, module,
@@ -784,15 +784,15 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
784784
}
785785
ma = (uint32_t)len;
786786
}
787-
tv->count = ma;
787+
tv->count = (int)ma;
788788
setByteArray(tif, &tv->value, mb, ma, 1);
789789
}
790790
else
791791
{
792792
if (fip->field_passcount)
793793
{
794794
if (fip->field_writecount == TIFF_VARIABLE2)
795-
tv->count = (uint32_t)va_arg(ap, uint32_t);
795+
tv->count = (int)va_arg(ap, uint32_t);
796796
else
797797
tv->count = (int)va_arg(ap, int);
798798
}
@@ -1861,7 +1861,7 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
18611861
uint16_t dircount;
18621862
uint32_t nextdir32;
18631863
poffa = (tmsize_t)poff;
1864-
poffb = poffa + sizeof(uint16_t);
1864+
poffb = poffa + (tmsize_t)sizeof(uint16_t);
18651865
if (((uint64_t)poffa != poff) || (poffb < poffa) ||
18661866
(poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size))
18671867
{
@@ -1875,7 +1875,7 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
18751875
if (tif->tif_flags & TIFF_SWAB)
18761876
TIFFSwabShort(&dircount);
18771877
poffc = poffb + dircount * 12;
1878-
poffd = poffc + sizeof(uint32_t);
1878+
poffd = poffc + (tmsize_t)sizeof(uint32_t);
18791879
if ((poffc < poffb) || (poffc < dircount * 12) || (poffd < poffc) ||
18801880
(poffd < (tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size))
18811881
{
@@ -1902,7 +1902,7 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
19021902
return (0);
19031903
}
19041904
poffa = (tmsize_t)poff;
1905-
poffb = poffa + sizeof(uint64_t);
1905+
poffb = poffa + (tmsize_t)sizeof(uint64_t);
19061906
if (poffb > tif->tif_size)
19071907
{
19081908
TIFFErrorExtR(tif, module,
@@ -1927,7 +1927,7 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
19271927
return (0);
19281928
}
19291929
poffc = poffb + dircount16 * 20;
1930-
poffd = poffc + sizeof(uint64_t);
1930+
poffd = poffc + (tmsize_t)sizeof(uint64_t);
19311931
if (poffd > tif->tif_size)
19321932
{
19331933
TIFFErrorExtR(tif, module, "Error fetching directory link");

frmts/gtiff/libtiff/tif_dirinfo.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
636636
if (tif->tif_fields && tif->tif_nfields > 0)
637637
{
638638
tif->tif_fields = (TIFFField **)_TIFFCheckRealloc(
639-
tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *),
639+
tif, tif->tif_fields, (tmsize_t)(tif->tif_nfields + n), (tmsize_t)sizeof(TIFFField *),
640640
reason);
641641
}
642642
else
@@ -667,7 +667,7 @@ int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
667667
/* Sort the field info by tag number */
668668
qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
669669

670-
return n;
670+
return (int)n;
671671
}
672672

673673
void _TIFFPrintFieldInfo(TIFF *tif, FILE *fd)
@@ -933,7 +933,7 @@ int TIFFFieldReadCount(const TIFFField *fip) { return fip->field_readcount; }
933933

934934
int TIFFFieldWriteCount(const TIFFField *fip) { return fip->field_writecount; }
935935

936-
int TIFFFieldIsAnonymous(const TIFFField *fip) { return fip->field_anonymous; }
936+
int TIFFFieldIsAnonymous(const TIFFField *fip) { return (int)fip->field_anonymous; }
937937

938938
const TIFFField *_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag,
939939
TIFFDataType dt)
@@ -1213,8 +1213,8 @@ int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
12131213
if (tif->tif_nfieldscompat > 0)
12141214
{
12151215
tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckRealloc(
1216-
tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1,
1217-
sizeof(TIFFFieldArray), reason);
1216+
tif, tif->tif_fieldscompat, (tmsize_t)(tif->tif_nfieldscompat + 1),
1217+
(tmsize_t)sizeof(TIFFFieldArray), reason);
12181218
}
12191219
else
12201220
{

0 commit comments

Comments
 (0)