summaryrefslogtreecommitdiff
path: root/public/include/XMP_Const.h
diff options
context:
space:
mode:
authorHubert Figuière <hub@figuiere.net>2017-03-26 01:10:11 -0400
committerHubert Figuière <hub@figuiere.net>2017-03-26 01:39:07 -0400
commitc34c1144dc479b1ae303fd4f11e0a1cfd1313d51 (patch)
tree0385012a9ed2c499dcd3147ca0e83b6927f8e12e /public/include/XMP_Const.h
parent7a3467d8bf594578828b6f69b5b8f2e316f43cb9 (diff)
2.4.x: Bug 100397 - Fix crash on malformed JPEG file
- Check the buffer doesn't overrun for the TIFF tag - Fix a use-after-free in exception handling - Fix two invalid memcpy() on overlapping memory
Diffstat (limited to 'public/include/XMP_Const.h')
-rw-r--r--public/include/XMP_Const.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/public/include/XMP_Const.h b/public/include/XMP_Const.h
index b8b904f..62fa38f 100644
--- a/public/include/XMP_Const.h
+++ b/public/include/XMP_Const.h
@@ -12,6 +12,9 @@
#include "XMP_Environment.h"
#include <stddef.h>
+ #include <stddef.h>
+ #include <string.h>
+ #include <stdlib.h>
#if XMP_MacBuild | XMP_iOSBuild // ! No stdint.h on Windows and some UNIXes.
#include <stdint.h>
@@ -1322,7 +1325,25 @@ public:
///
/// @param _errMsg The descriptive string, for debugging use only. It must not be shown to users
/// in a final product. It is written for developers, not users, and never localized.
- XMP_Error ( XMP_Int32 _id, XMP_StringPtr _errMsg ) : id(_id), errMsg(_errMsg), notified(false) {};
+ XMP_Error ( XMP_Int32 _id, XMP_StringPtr _errMsg ) : id(_id), errMsg(NULL), notified(false) {
+ if (_errMsg) {
+ errMsg = strdup(_errMsg);
+ }
+ };
+ /// @brief Copy constructor for an XMP_Error.
+ ///
+ /// Because we rethrow it.
+ XMP_Error (const XMP_Error& e)
+ : id(e.id), errMsg(NULL), notified(e.notified) {
+ if (e.errMsg) {
+ errMsg = strdup(e.errMsg);
+ }
+ };
+ ~XMP_Error() {
+ if (errMsg) {
+ free(errMsg);
+ }
+ };
/// Retrieves the numeric code from an XMP_Error.
inline XMP_Int32 GetID() const { return id; };
@@ -1341,7 +1362,7 @@ private:
XMP_Int32 id;
/// Descriptive string, for debugging use only. It must not be shown to users in a final
/// product. It is written for developers, not users, and never localized.
- XMP_StringPtr errMsg;
+ char* errMsg;
/// Variable to store whether this particular error is notified to user or not
XMP_Bool notified;
};