diff options
author | Andrey Kiselev <dron@ak4719.spb.edu> | 2007-04-10 16:14:34 +0000 |
---|---|---|
committer | Andrey Kiselev <dron@ak4719.spb.edu> | 2007-04-10 16:14:34 +0000 |
commit | c68178ad3b97c362ff41400c746f88711506aaa1 (patch) | |
tree | 94aadd253719ff9f0ecdd3b0227684086f23fdf4 /libtiff/tif_dirinfo.c | |
parent | 60207197ade59fb2e0cae05dc483002013a7ab5a (diff) | |
download | libtiff-git-c68178ad3b97c362ff41400c746f88711506aaa1.tar.gz |
Get rid of assert() in _TIFFMergeFieldInfo() since we can return erroneus
status now.
Diffstat (limited to 'libtiff/tif_dirinfo.c')
-rw-r--r-- | libtiff/tif_dirinfo.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c index 9c75e4a3..bc0ca961 100644 --- a/libtiff/tif_dirinfo.c +++ b/libtiff/tif_dirinfo.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirinfo.c,v 1.65.2.1 2007-04-07 14:58:30 dron Exp $ */ +/* $Id: tif_dirinfo.c,v 1.65.2.2 2007-04-10 16:14:34 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -591,6 +591,8 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) int _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) { + const char module[] = "_TIFFMergeFieldInfo"; + const char reason[] = "for field info array"; TIFFFieldInfo** tp; int i; @@ -598,7 +600,7 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int 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); @@ -610,13 +612,19 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int 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 */ @@ -755,7 +763,7 @@ _TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) tif->tif_fieldinfo, tif->tif_nfields, sizeof(TIFFFieldInfo *), - tagCompare); + tagCompare); return tif->tif_foundfield = (ret ? *ret : NULL); } @@ -776,9 +784,9 @@ _TIFFFindFieldInfoByName(TIFF* tif, const char *field_name, TIFFDataType dt) ret = (const TIFFFieldInfo **) lfind(&pkey, tif->tif_fieldinfo, - &tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagNameCompare); + &tif->tif_nfields, + sizeof(TIFFFieldInfo *), + tagNameCompare); return tif->tif_foundfield = (ret ? *ret : NULL); } |