[mapguide-commits] r10128 - in branches/4.0/MgDev: Oem/DWFTK/develop/global/src/dwf/whiptk Server/src/Services/Drawing Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Mar 26 07:00:20 PDT 2025
Author: jng
Date: 2025-03-26 07:00:19 -0700 (Wed, 26 Mar 2025)
New Revision: 10128
Modified:
branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/informational.cpp
branches/4.0/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp
branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp
Log:
Improve drawing service test stability on Linux in debug mode. The offenders were usages of strrchr() on raw buffers triggering ASAN heap overflow errors on Linux. Such usages on Linux are either stubbed out or replaced with a std::string-based intermediate buffer
Modified: branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/informational.cpp
===================================================================
--- branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/informational.cpp 2025-03-26 13:44:54 UTC (rev 10127)
+++ branches/4.0/MgDev/Oem/DWFTK/develop/global/src/dwf/whiptk/informational.cpp 2025-03-26 14:00:19 UTC (rev 10128)
@@ -108,6 +108,7 @@
WD_Complain ("WT_Informational::preprocess_workarounds is not implemented on this system");
#endif
+ #ifdef _WIN32
if( (strstr(pNarrow, "Genuine AutoCAD 2000i (15.05") != NULL) || // Banff release
(strstr(pNarrow, "Genuine AutoCAD 2000 (15.0") != NULL) || // Tahoe release
(strstr(pNarrow, "Genuine AutoCAD 2000i (U") != NULL) || // Banff pre-release
@@ -115,6 +116,9 @@
{
file.heuristics().set_broken_plotinfo(WD_True);
}
+ #else
+ // Don't bother testing
+ #endif
delete [] pNarrow;
}
return WT_Result::Success;
Modified: branches/4.0/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp 2025-03-26 13:44:54 UTC (rev 10127)
+++ branches/4.0/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp 2025-03-26 14:00:19 UTC (rev 10128)
@@ -105,6 +105,9 @@
// Obtain the manifest from the DWF.
DWFInputStream* pStream = reader->extract(MANIFEST_XML.c_str(), false);
size_t nBytes = pStream->available();
+
+#ifdef _WIN32
+
char* pBuffer = DWFCORE_ALLOC_MEMORY( char, nBytes );
pStream->read(pBuffer, nBytes);
@@ -134,10 +137,34 @@
byteSource->SetMimeType(MgMimeType::Xml);
byteReader = byteSource->GetReader();
+ if (0 != pBuffer)
+ DWFCORE_FREE_MEMORY(pBuffer);
+
+#else
+ std::string buf;
+ if (nBytes)
+ {
+ char pBuf[1024];
+ do
+ {
+ auto nBytesRead = pStream->read(pBuf, sizeof(pBuf));
+ if (nBytesRead)
+ {
+ buf.append(pBuf, nBytesRead);
+ }
+ nBytes = pStream->available();
+ } while (nBytes);
+ }
+ auto lastIndex = buf.find_last_of('>'); // NOXLATE
+ if (lastIndex != std::string::npos)
+ {
+ Ptr<MgByteSource> byteSource = new MgByteSource((BYTE_ARRAY_IN)buf.c_str(), lastIndex + 1);
+ byteSource->SetMimeType(MgMimeType::Xml);
+ byteReader = byteSource->GetReader();
+ }
+#endif
if (0 != pStream)
DWFCORE_FREE_OBJECT(pStream);
- if (0 != pBuffer)
- DWFCORE_FREE_MEMORY(pBuffer);
}
MgServerDrawingServiceUtil::CloseDrawingResource(m_bOpenTempDwfFile, m_tempDwfFileName);
@@ -441,7 +468,7 @@
CHECKNULL(pStream, L"MgServerDrawingService.EnumerateLayers");
size_t nBytes = pStream->available();
char* pBuffer = DWFCORE_ALLOC_MEMORY( char, nBytes );
- pStream->read(pBuffer, nBytes);
+ size_t nBytesRead = pStream->read(pBuffer, nBytes);
DWFCORE_FREE_OBJECT(pStream);
CHECKNULL(pBuffer, L"MgServerDrawingService.EnumerateLayers");
Modified: branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp 2025-03-26 13:44:54 UTC (rev 10127)
+++ branches/4.0/MgDev/Server/src/UnitTesting/TestDrawingService.cpp 2025-03-26 14:00:19 UTC (rev 10128)
@@ -28,6 +28,7 @@
Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
Ptr<MgByteReader> rdr1 = m_svcDrawing->DescribeDrawing(resId1);
+ //auto content = rdr1->ToString();
REQUIRE(MgMimeType::Xml == rdr1->GetMimeType());
}
catch (MgException* e)
More information about the mapguide-commits
mailing list