AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1994.10.21 15:50 "Problems catching write errors in tiff library (v3.3beta021)", by Ben Griffin
1994.10.21 03:20 "Re: Problems catching write errors in tiff library (v3.3beta021)", by Richard Minner
1994.10.21 05:53 "Re: C++ tiff library", by Richard Minner
1994.10.21 23:15 "Re: C++ tiff library", by Yip Chi Lap
1994.10.21 14:38 "Re: C++ tiff library", by Richard Minner
1994.10.25 20:49 "Re: C++ tiff library", by John M Davison
1994.10.31 04:52 "Re: C++ tiff library", by Richard Minner
1994.10.21 17:12 "Re: Problems catching write errors in tiff library (v3.3beta021)", by Dan McCoy
1994.10.21 18:36 "C++ tiff library", by Jim Arnold
1994.10.21 18:53 "Re: Problems catching write errors in tiff library (v3.3beta021)", by John Bradley
1994.10.21 19:16 "Re: Problems catching write errors in tiff library (v3.3beta021)", by Sam Leffler
1994.10.21 19:13 "Re: Problems catching write errors in tiff library (v3.3beta021)", by Sam Leffler

1994.10.21 15:50 "Problems catching write errors in tiff library (v3.3beta021)", by Ben Griffin

Version: 3.3beta021 Host: Sparc Solaris 2.3

There seems to have an incongruity in the return types of the tiff_encoderow functions as follows.

   TIFFNoRowEncode returns -1 on failure.
   DumpModeEncode  returns -1 on failure.
   Fax3Encode      returns  0 on failure.
   Fax4Encode      returns  0 on failure.
   LZWEncode       returns  0 on failure.
   PackBitsEncode  returns -1 on failure.

This can cause TIFFWriteScanLine to return a non -1 value (0) which does not indicate an error. I discovered this after running disk full tests with our app which uses the tiff library.

I guess you are safe if you check for a success return value (1) from TIFFWriteScanLine, but I happend to be checking for the failure which is -1 according to the man page (I guess that is why it's beta eh?).

The fix (kludge) I put in tif_write to aleviate this is: line 155: (second to last line in TIFFWriteScanLine)

  if ( status == 0 ) status = -1;

Other areas that could cause uncaught errors:

Here are the diffs for my fixes:

cvs diff: Diffing .
===================================================================
RCS file: tif_close.c,v
retrieving revision 1.2
diff -r1.2 tif_close.c
32c32
< void
---
> int
34a35
>    int status = 1;
39c40
<               TIFFFlush(tif);
---
>       if (!TIFFFlush(tif)) status = 0;
47c48
<       (void) TIFFCloseFile(tif);
---
>       if (TIFFCloseFile(tif)==-1) status = 0;
48a50
>    return status;
===================================================================
RCS file: tif_fax3.c,v
retrieving revision 1.3
diff -r1.3 tif_fax3.c
703c703
< void
---
> int
718a719
>    return 1;
724c725
< static void
---
> static int
727c728
<       Fax3PutBits(tif, te->code, te->length);
---
>       return Fax3PutBits(tif, te->code, te->length);
736c737
< static void
---

> static int
741c742
<               putcode(tif, te);
---
>               if (!putcode(tif, te)) return 0;
747c748
<               putcode(tif, te);
---
>               if (!putcode(tif, te)) return 0;
750c751
<       putcode(tif, &tab[span]);
---
>       return putcode(tif, &tab[span]);
759c760
< void
---
> int
776c777
<                       Fax3PutBits(tif, 0, align);
---
>                       if (!Fax3PutBits(tif, 0, align))return 0;
779c780
<       Fax3PutBits(tif, EOL, 12);
---
>       if (!Fax3PutBits(tif, EOL, 12))return 0;
781c782,783
<               Fax3PutBits(tif, sp->tag == G3_1D, 1);
---
>               if (!Fax3PutBits(tif, sp->tag == G3_1D, 1))return 0;
>    return 1;
878c880
<               putspan(tif, span, TIFFFaxWhiteCodes);
---
>               if ( !putspan(tif, span, TIFFFaxWhiteCodes)) return 0;
883c885
<               putspan(tif, span, TIFFFaxBlackCodes);
---
>               if (!putspan(tif, span, TIFFFaxBlackCodes)) return 0;
889c891
<               Fax3PutBits(tif, 0, sp->b.bit);
---
>               if (!Fax3PutBits(tif, 0, sp->b.bit)) return 0;
891c893
<                       Fax3PutBits(tif, 0, 8);
---
>                       if (!Fax3PutBits(tif, 0, 8))return 0;
929c931
<                               putcode(tif, &horizcode);
---
>                               if (!putcode(tif, &horizcode)) return 0;
931,932c933,934
<                                       putspan(tif, a1-a0, TIFFFaxWhiteCodes);
<                                       putspan(tif, a2-a1, TIFFFaxBlackCodes);
---
>                                       if (!putspan(tif, a1-a0, TIFFFaxWhiteCodes))return 0;
>                                       if (!putspan(tif, a2-a1, TIFFFaxBlackCodes))return 0;
934,935c936,937

<                                       putspan(tif, a1-a0, TIFFFaxBlackCodes);
<                                       putspan(tif, a2-a1, TIFFFaxWhiteCodes);
---
>                                       if (!putspan(tif, a1-a0, TIFFFaxBlackCodes))return 0;
>                                       if (!putspan(tif, a2-a1, TIFFFaxWhiteCodes))return 0;
939c941
<                               putcode(tif, &vcodes[d+3]);
---
>                               if (!putcode(tif, &vcodes[d+3])) return 0;
943c945
<                       putcode(tif, &passcode);
---
>                       if (!putcode(tif, &passcode)) return 0;
966c968
<                       Fax3PutEOL(tif);
---
>                       if (!Fax3PutEOL(tif))return 0;
1004c1006
< static void
---
> static int
1010c1012
<                   Fax3PutBits(tif, EOL, 12);
---
>                   if (!Fax3PutBits(tif, EOL, 12))return 0;
1012c1014
<                           Fax3PutBits(tif, 1, 1);
---
>                           if (!Fax3PutBits(tif, 1, 1))return 0;
1015a1018
>    return 1;
===================================================================
RCS file: tif_fax3.h,v
retrieving revision 1.2
diff -r1.2 tif_fax3.h
58,59c58,59
< extern        void Fax3PutBits(TIFF*, u_int, u_int);
< extern        void Fax3PutEOL(TIFF*);
---
> extern        int Fax3PutBits(TIFF*, u_int, u_int);
> extern        int Fax3PutEOL(TIFF*);
64c64
<               (void) TIFFFlushData1(tif);             \
---
>       if ( TIFFFlushData1(tif) == 0 ) return 0;               \
===================================================================
RCS file: tif_fax4.c,v
retrieving revision 1.2
diff -r1.2 tif_fax4.c
80c80
< static
---
> static int
86,87c86,87
<       Fax3PutBits(tif, EOL, 12);
<       Fax3PutBits(tif, EOL, 12);
---
>       if ( !Fax3PutBits(tif, EOL, 12))return 0;
>       if ( !Fax3PutBits(tif, EOL, 12))return 0;
===================================================================
RCS file: tif_write.c,v
retrieving revision 1.2
diff -r1.2 tif_write.c
154a155
>    if ( status == 0 ) status = -1;
===================================================================
RCS file: tiffio.h,v
retrieving revision 1.2
diff -r1.2 tiffio.h
117c117
< extern        void TIFFClose(TIFF*);
---
> extern        int TIFFClose(TIFF*);



===================================================================

On another subject, there was some talk earlier about rewriting the tiff library in C++. Any progress on this? Want any help?

Ben Griffin
Harris Criminal Justice Products
griffin@sur1a.hisd.hpsc.harris.com