From ff1d8bf5c1ee4edec5d0730cef68f023b9c2f786 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Tue, 10 Apr 2007 16:15:04 +0000 Subject: [PATCH] Get rid of assert() in _TIFFMergeFieldInfo() since we can return erroneus status now. --- libtiff/tif_dirinfo.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c index e50dbcd8..34810814 100644 --- a/libtiff/tif_dirinfo.c +++ b/libtiff/tif_dirinfo.c @@ -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 @@ -621,6 +621,8 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) int _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) { + const char module[] = "_TIFFMergeFieldInfo"; + const char reason[] = "for field info array"; TIFFFieldInfo** tp; uint32 i; @@ -628,7 +630,7 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) const TIFFFieldInfo *fip = _TIFFFindFieldInfo(tif, info[i].field_tag, TIFF_ANY); if (fip) { - TIFFErrorExt(tif->tif_clientdata, "_TIFFMergeFieldInfo", + TIFFErrorExt(tif->tif_clientdata, module, "Field with tag %lu is already registered as \"%s\"", (unsigned int) info[i].field_tag, fip->field_name); @@ -640,13 +642,19 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) if (tif->tif_nfields > 0) { tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFrealloc(tif->tif_fieldinfo, - (tif->tif_nfields + n) * sizeof (TIFFFieldInfo*)); + _TIFFCheckRealloc(tif, tif->tif_fieldinfo, + (tif->tif_nfields + n), + sizeof (TIFFFieldInfo*), reason); } else { 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; for (i = 0; i < n; i++) *tp++ = (TIFFFieldInfo*) (info + i); /* XXX */