r23778 by jghali - Fix potential null pointer dereference

scribus-commit scribus-commit at lists.scribus.net
Mon May 11 20:06:56 UTC 2020


Author: jghali
Date: Mon May 11 20:06:55 2020
New Revision: 23778

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23778
Log:
Fix potential null pointer dereference

Modified:
    trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.cpp
    trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp

Modified: trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23778&path=/trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.cpp	(original)
+++ trunk/Scribus/scribus/colormgmt/sclcms2colormgmtengineimpl.cpp	Mon May 11 20:06:55 2020
@@ -88,8 +88,9 @@
 			if (descSize > 0)
 			{
 				wchar_t* descData = (wchar_t*) malloc(descSize + sizeof(wchar_t));
-				descSize = cmsGetProfileInfo(hIn, cmsInfoDescription, "en", "US", descData, descSize);
-				if (descSize > 0)
+				if (descData)
+					descSize = cmsGetProfileInfo(hIn, cmsInfoDescription, "en", "US", descData, descSize);
+				if (descData && (descSize > 0))
 				{
 					uint stringLen = descSize / sizeof(wchar_t);
 					descData[stringLen] = 0;
@@ -98,20 +99,19 @@
 					} else {
 						profileInfo.description = QString::fromUcs4((uint *) descData);
 					}
-					free(descData);
 				}
+				free(descData);
 			}
 #else
 			cmsUInt32Number descSize = cmsGetProfileInfoASCII(hIn, cmsInfoDescription, "en", "US", nullptr, 0);
 			if (descSize > 0)
 			{
 				char* descData = (char*) malloc(descSize + sizeof(char));
-				descSize = cmsGetProfileInfoASCII(hIn, cmsInfoDescription, "en", "US", descData, descSize);
-				if (descSize > 0)
-				{
+				if (descData)
+					descSize = cmsGetProfileInfoASCII(hIn, cmsInfoDescription, "en", "US", descData, descSize);
+				if (descData && (descSize > 0))
 					profileInfo.description = QString(descData);
-					free(descData);
-				}
+				free(descData);
 			}
 #endif
 			if (profileInfo.description.isEmpty())

Modified: trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23778&path=/trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp	(original)
+++ trunk/Scribus/scribus/colormgmt/sclcms2colorprofileimpl.cpp	Mon May 11 20:06:55 2020
@@ -63,8 +63,9 @@
 			if (descSize > 0)
 			{
 				wchar_t* descData = (wchar_t*) malloc(descSize + sizeof(wchar_t));
-				descSize = cmsGetProfileInfo(m_profileHandle, cmsInfoDescription, "en", "US", descData, descSize);
-				if (descSize > 0)
+				if (descData)
+					descSize = cmsGetProfileInfo(m_profileHandle, cmsInfoDescription, "en", "US", descData, descSize);
+				if (descData && (descSize > 0))
 				{
 					uint stringLen = descSize / sizeof(wchar_t);
 					descData[stringLen] = 0;
@@ -73,20 +74,19 @@
 					} else {
 						m_productDescription = QString::fromUcs4((uint *) descData);
 					}
-					free(descData);
 				}
+				free(descData);
 			}
 #else
 			cmsUInt32Number descSize = cmsGetProfileInfoASCII(m_profileHandle, cmsInfoDescription, "en", "US", nullptr, 0);
 			if (descSize > 0)
 			{
 				char* descData = (char*) malloc(descSize + sizeof(char));
-				descSize = cmsGetProfileInfoASCII(m_profileHandle, cmsInfoDescription, "en", "US", descData, descSize);
-				if (descSize > 0)
-				{
+				if (descData)
+					descSize = cmsGetProfileInfoASCII(m_profileHandle, cmsInfoDescription, "en", "US", descData, descSize);
+				if (descData && (descSize > 0))
 					m_productDescription = QString(descData);
-					free(descData);
-				}
+				free(descData);
 			}
 #endif
 		}




More information about the scribus-commit mailing list