libtiff: *** empty log message *** (3ce28)

https://github.com/libsdl-org/libtiff/commit/3ce2857b1860ab3ca57ece298dde3a3b4a4b9a6b

From 3ce2857b1860ab3ca57ece298dde3a3b4a4b9a6b Mon Sep 17 00:00:00 2001
From: Andrey Kiselev <[EMAIL REDACTED]>
Date: Wed, 30 Jun 2010 16:05:56 +0000
Subject: [PATCH] *** empty log message ***

---
 ChangeLog        |  3 +++
 tools/tiff2pdf.c | 39 ++++++++++++---------------------------
 2 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8b748ba..9316ab82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2010-06-30  Andrey Kiselev  <dron@ak4719.spb.edu>
 
+	* tools/tiff2pdf.c: Better generation of ID field in
+	t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings.
+
 	* tools/tiff2pdf.c: Fixed computation of the tile buffer size when
 	converting JPEG encoded tiles.
 
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 3c4147ba..0a75a6ce 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -1,4 +1,4 @@
-/* $Id: tiff2pdf.c,v 1.37.2.13 2010-06-30 15:43:27 dron Exp $
+/* $Id: tiff2pdf.c,v 1.37.2.14 2010-06-30 16:05:56 dron Exp $
  *
  * tiff2pdf - converts a TIFF image to a PDF document
  *
@@ -193,7 +193,8 @@ typedef struct {
 	uint32 pdf_palettecs;
 	uint16 pdf_fitwindow;
 	uint32 pdf_startxref;
-	unsigned char* pdf_fileid;
+#define TIFF2PDF_FILEID_SIZE 33
+	char pdf_fileid[TIFF2PDF_FILEID_SIZE];
 #define TIFF2PDF_DATETIME_SIZE 17
 	char pdf_datetime[TIFF2PDF_DATETIME_SIZE];
 #define TIFF2PDF_CREATOR_SIZE 512
@@ -929,9 +930,6 @@ void t2p_free(T2P* t2p)
 		if(t2p->pdf_palette != NULL){
 			_TIFFfree( (tdata_t) t2p->pdf_palette);
 		}
-		if(t2p->pdf_fileid != NULL){
-			_TIFFfree( (tdata_t) t2p->pdf_fileid);
-		}
 #ifdef OJPEG_SUPPORT
 		if(t2p->pdf_ojpegdata != NULL){
 			_TIFFfree( (tdata_t) t2p->pdf_ojpegdata);
@@ -5050,27 +5048,12 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
 	tsize_t written = 0;
 	char buffer[32];
 	int buflen = 0;
-	char fileidbuf[16];
-	int i = 0;
+	size_t i = 0;
+
+	for (i = 0; i < sizeof(t2p->pdf_fileid); i += 8)
+		snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand());
+	t2p->pdf_fileid[sizeof(t2p->pdf_fileid) - 1] = '\0';
 
-	((int*)fileidbuf)[0] = rand();
-	((int*)fileidbuf)[1] = rand();
-	((int*)fileidbuf)[2] = rand();
-	((int*)fileidbuf)[3] = rand();
-	t2p->pdf_fileid = (unsigned char*)_TIFFmalloc(33);
-	if(t2p->pdf_fileid == NULL) {
-		TIFFError(
-			TIFF2PDF_MODULE, 
-		"Can't allocate %u bytes of memory for t2p_write_pdf_trailer", 
-			33 );
-		t2p->t2p_error = T2P_ERR_ERROR;
-		return(0);
-	}
-	_TIFFmemset(t2p->pdf_fileid, 0x00, 33);
-	for (i = 0; i < 16; i++) {
-		sprintf((char *)t2p->pdf_fileid + 2 * i,
-			"%.2hhX", fileidbuf[i]);
-	}
 	written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17);
 	buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
 	written += t2pWriteFile(output, (tdata_t) buffer, buflen);
@@ -5084,9 +5067,11 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
 	written += t2pWriteFile(output, (tdata_t) buffer, buflen);
 	_TIFFmemset(buffer, 0x00, 32);	
 	written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11);
-	written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, 32);
+	written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
+				sizeof(t2p->pdf_fileid) - 1);
 	written += t2pWriteFile(output, (tdata_t) "><", 2);
-	written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, 32);
+	written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
+				sizeof(t2p->pdf_fileid) - 1);
 	written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16);
 	buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref);
 	written += t2pWriteFile(output, (tdata_t) buffer, buflen);