OLD | NEW |
1 /* $Id: tif_dirwrite.c,v 1.77 2012-07-06 19:18:31 bfriesen Exp $ */ | 1 /* $Id: tif_dirwrite.c,v 1.78 2015-05-31 00:38:46 bfriesen Exp $ */ |
2 | 2 |
3 /* | 3 /* |
4 * Copyright (c) 1988-1997 Sam Leffler | 4 * Copyright (c) 1988-1997 Sam Leffler |
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. | 5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. |
6 * | 6 * |
7 * Permission to use, copy, modify, distribute, and sell this software and | 7 * Permission to use, copy, modify, distribute, and sell this software and |
8 * its documentation for any purpose is hereby granted without fee, provided | 8 * its documentation for any purpose is hereby granted without fee, provided |
9 * that (i) the above copyright notices and this permission notice appear in | 9 * that (i) the above copyright notices and this permission notice appear in |
10 * all copies of the software and related documentation, and (ii) the names of | 10 * all copies of the software and related documentation, and (ii) the names of |
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or | 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 if( !value_in_entry ) | 2832 if( !value_in_entry ) |
2833 { | 2833 { |
2834 entry_offset = TIFFSeekFile(tif,0,SEEK_END); | 2834 entry_offset = TIFFSeekFile(tif,0,SEEK_END); |
2835 | 2835 |
2836 if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { | 2836 if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { |
2837 _TIFFfree( buf_to_write ); | 2837 _TIFFfree( buf_to_write ); |
2838 TIFFErrorExt(tif->tif_clientdata, module, | 2838 TIFFErrorExt(tif->tif_clientdata, module, |
2839 "Error writing directory link"); | 2839 "Error writing directory link"); |
2840 return (0); | 2840 return (0); |
2841 } | 2841 } |
2842 | |
2843 _TIFFfree( buf_to_write ); | |
2844 } | 2842 } |
2845 else | 2843 else |
2846 { | 2844 { |
2847 memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype)); | 2845 memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype)); |
2848 } | 2846 } |
2849 | 2847 |
| 2848 _TIFFfree( buf_to_write ); |
| 2849 buf_to_write = 0; |
| 2850 |
2850 /* -------------------------------------------------------------------- */ | 2851 /* -------------------------------------------------------------------- */ |
2851 /* Adjust the directory entry. */ | 2852 /* Adjust the directory entry. */ |
2852 /* -------------------------------------------------------------------- */ | 2853 /* -------------------------------------------------------------------- */ |
2853 entry_type = datatype; | 2854 entry_type = datatype; |
2854 memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); | 2855 memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); |
2855 if (tif->tif_flags&TIFF_SWAB) | 2856 if (tif->tif_flags&TIFF_SWAB) |
2856 TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); | 2857 TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); |
2857 | 2858 |
2858 if (!(tif->tif_flags&TIFF_BIGTIFF)) | 2859 if (!(tif->tif_flags&TIFF_BIGTIFF)) |
2859 { | 2860 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 return 1; | 2902 return 1; |
2902 } | 2903 } |
2903 /* vim: set ts=8 sts=8 sw=8 noet: */ | 2904 /* vim: set ts=8 sts=8 sw=8 noet: */ |
2904 /* | 2905 /* |
2905 * Local Variables: | 2906 * Local Variables: |
2906 * mode: c | 2907 * mode: c |
2907 * c-basic-offset: 8 | 2908 * c-basic-offset: 8 |
2908 * fill-column: 78 | 2909 * fill-column: 78 |
2909 * End: | 2910 * End: |
2910 */ | 2911 */ |
OLD | NEW |