Skip navigation
HenrikT
Currently Being Moderated

XMP SDK 5.1.2 error "pointer being freed was not allocated"

Apr 12, 2012 5:12 AM

Tags: #xmp

Hi,

 

I have found an error in the SDK handling rewrite of JPEG APP13 photoshop blocks. The error happens when an existing resource block changes data, and rsrcName is kept.

 

suggested sollution in source/XMPFiles/FormatSupport/PSIR_Support.hpp

 

in the class PSIR_FileWriter - struct InternalRsrcInfo:

 

 

@@ -246,7 +246,17 @@ public:

        struct InternalRsrcInfo {

        public:

 

+#define HT_CHANGED 1

+#ifdef HT_CHANGED

+               bool      changed; // Meaning dataPtr has changed. rsrcName is never changed

+               // see e.g. SetImgRsrc (when changed content of data - else part),

+               // where dataPtr is freed and and new

+               // block is allocated. rsrcName is not realloc'ed - will

+               // then fail with free error in FreeName below with free

+               // "pointer being freed was not allocated"

+#else

                bool      changed;

+#endif

                bool      fileBased;

                XMP_Uns16 id;

                XMP_Uns32 dataLen;

@@ -261,7 +271,11 @@ public:

                }

 

                inline void FreeName() {

+#ifdef HT_CHANGED

+                       if ( this->fileBased ) {

+#else

                        if ( this->fileBased || this->changed ) {

+#endif

                                if ( this->rsrcName != 0 ) { free ( this->rsrcName ); this->rsrcName = 0; }

                        }

                }

 

 

 

 

 

fileBased is false.

 

 

This resolves my problem. Please consider including this in future release.

 

Comments / questions are welcome.

 

/Henrik

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points