r20717 by craig -

scribus-commit scribus-commit at lists.scribus.net
Mon Jan 25 06:04:05 UTC 2016


Author: craig
Date: Mon Jan 25 06:04:05 2016
New Revision: 20717

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20717
Log:
#Fix warnings in pdbmim.h/.cpp. Properly close opened file

Modified:
    trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.cpp
    trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.h

Modified: trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20717&path=/trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.cpp	(original)
+++ trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.cpp	Mon Jan 25 06:04:05 2016
@@ -97,7 +97,12 @@
 							 QMessageBox::Ok, QMessageBox::NoButton);
 		return;
 	}
-	fread( &m_header, PDB_HEADER_SIZE, 1, m_pdfp );
+	size_t result = fread( &m_header, PDB_HEADER_SIZE, 1, m_pdfp );
+	if (result != PDB_HEADER_SIZE)
+	{
+		fclose(m_pdfp);
+		return;
+	}
 	if (strncmp(m_header.type, DOC_TYPE, sizeof(m_header.type) ) ||
 		strncmp( m_header.creator, DOC_CREATOR, sizeof(m_header.creator)))
 	{
@@ -113,8 +118,12 @@
 	fseek(m_pdfp, PDB_HEADER_SIZE, SEEK_SET);
 	GET_DWord(m_pdfp, offset);
 	fseek(m_pdfp, offset, SEEK_SET);
-	fread(&m_rec0, sizeof(m_rec0), 1, m_pdfp);
-
+	result = fread(&m_rec0, sizeof(m_rec0), 1, m_pdfp);
+	if (result != sizeof(m_rec0))
+	{
+		fclose(m_pdfp);
+		return;
+	}
 	if (swap_Word( m_rec0.version ) == 2 )
 		bCompressed = true;
 
@@ -154,6 +163,7 @@
 			++m_buf->position;
 		} 
 	}
+	fclose(m_pdfp);
 }
 
 void PdbIm::selectSwap()

Modified: trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20717&path=/trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.h	(original)
+++ trunk/Scribus/scribus/plugins/gettext/pdbim/pdbim.h	Mon Jan 25 06:04:05 2016
@@ -96,8 +96,8 @@
 	UT_uint32   position;
 } buffer;
 
-#define GET_Word(f,n)   { fread( &n, 2, 1, f ); n = swap_Word ( n ); }
-#define GET_DWord(f,n)  { fread( &n, 4, 1, f ); n = swap_DWord( n ); }
+#define GET_Word(f,n)   { size_t result = fread( &n, 2, 1, f ); if (result == 2) n = swap_Word ( n ); }
+#define GET_DWord(f,n)  { size_t result = fread( &n, 4, 1, f ); if (result == 4) n = swap_DWord( n ); }
 
 /*! \brief An import filter for Palm Documents (PDB files).
 PDB documents are simple non-formatted texts in binary forms used




More information about the scribus-commit mailing list