Get rid of assert() in _TIFFMergeFieldInfo() since we can return erroneus

status now.
This commit is contained in:
Andrey Kiselev 2007-04-10 16:15:04 +00:00
parent ebbeebb943
commit ff1d8bf5c1

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirinfo.c,v 1.73 2007-04-09 18:03:30 joris Exp $ */ /* $Id: tif_dirinfo.c,v 1.74 2007-04-10 16:15:04 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -621,6 +621,8 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
int int
_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
{ {
const char module[] = "_TIFFMergeFieldInfo";
const char reason[] = "for field info array";
TIFFFieldInfo** tp; TIFFFieldInfo** tp;
uint32 i; uint32 i;
@ -628,7 +630,7 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
const TIFFFieldInfo *fip = const TIFFFieldInfo *fip =
_TIFFFindFieldInfo(tif, info[i].field_tag, TIFF_ANY); _TIFFFindFieldInfo(tif, info[i].field_tag, TIFF_ANY);
if (fip) { if (fip) {
TIFFErrorExt(tif->tif_clientdata, "_TIFFMergeFieldInfo", TIFFErrorExt(tif->tif_clientdata, module,
"Field with tag %lu is already registered as \"%s\"", "Field with tag %lu is already registered as \"%s\"",
(unsigned int) info[i].field_tag, (unsigned int) info[i].field_tag,
fip->field_name); fip->field_name);
@ -640,13 +642,19 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
if (tif->tif_nfields > 0) { if (tif->tif_nfields > 0) {
tif->tif_fieldinfo = (TIFFFieldInfo**) tif->tif_fieldinfo = (TIFFFieldInfo**)
_TIFFrealloc(tif->tif_fieldinfo, _TIFFCheckRealloc(tif, tif->tif_fieldinfo,
(tif->tif_nfields + n) * sizeof (TIFFFieldInfo*)); (tif->tif_nfields + n),
sizeof (TIFFFieldInfo*), reason);
} else { } else {
tif->tif_fieldinfo = (TIFFFieldInfo**) tif->tif_fieldinfo = (TIFFFieldInfo**)
_TIFFmalloc(n * sizeof (TIFFFieldInfo*)); _TIFFCheckMalloc(tif, n, sizeof (TIFFFieldInfo*),
reason);
}
if (!tif->tif_fieldinfo) {
TIFFErrorExt(tif->tif_clientdata, module,
"Failed to allocate field info array");
return 0;
} }
assert(tif->tif_fieldinfo != NULL);
tp = tif->tif_fieldinfo + tif->tif_nfields; tp = tif->tif_fieldinfo + tif->tif_nfields;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
*tp++ = (TIFFFieldInfo*) (info + i); /* XXX */ *tp++ = (TIFFFieldInfo*) (info + i); /* XXX */