File r1921-m_offsets-resize-can-throw-std-length_error-as-well-as-std-bad_alloc.patch of Package podofo.23799
------------------------------------------------------------------------
r1921 | domseichter | 2018-04-14 09:47:38 +0200 (sáb, 14 abr 2018) | 1 line
FIXED by Mark Rogers: m_offsets.resize() can throw std::length_error as well as std::bad_alloc.
Index: src/base/PdfParser.cpp
===================================================================
--- src/base/PdfParser.cpp (revision 1920)
+++ src/base/PdfParser.cpp (revision 1921)
@@ -805,7 +805,13 @@
m_nNumObjects = nFirstObject + nNumObjects;
m_offsets.resize(nFirstObject+nNumObjects);
#endif // _WIN32
- } catch (std::bad_alloc &) {
+ } catch (std::exception &) {
+ // If m_nNumObjects*sizeof(TXRefEntry) > std::numeric_limits<size_t>::max() then
+ // resize() throws std::length_error, for smaller allocations that fail it may throw
+ // std::bad_alloc (implementation-dependent). "20.5.5.12 Restrictions on exception
+ // handling" in the C++ Standard says any function that throws an exception is allowed
+ // to throw implementation-defined exceptions derived the base type (std::exception)
+ // so we need to catch all std::exceptions here
PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
}
}
------------------------------------------------------------------------