@@ -217,10 +217,10 @@ void GDALJP2Metadata::CollectGMLData(GDALJP2Box *poGMLData)
217217
218218 while (strlen (oSubChildBox.GetType ()) > 0 )
219219 {
220- if (EQUAL (oSubChildBox.GetType (), " lbl " ))
220+ if (EQUAL (oSubChildBox.GetType (), " lbl " ) && !pszLabel )
221221 pszLabel =
222222 reinterpret_cast <char *>(oSubChildBox.ReadBoxData ());
223- else if (EQUAL (oSubChildBox.GetType (), " xml " ))
223+ else if (EQUAL (oSubChildBox.GetType (), " xml " ) && !pszXML )
224224 {
225225 pszXML =
226226 reinterpret_cast <char *>(oSubChildBox.ReadBoxData ());
@@ -3333,7 +3333,7 @@ GDALJP2Metadata::CreateGDALMultiDomainMetadataXMLBox(GDALDataset *poSrcDS,
33333333
33343334 GDALJP2Box *poBox = new GDALJP2Box ();
33353335 poBox->SetType (" xml " );
3336- poBox->SetWritableData (static_cast <int >(strlen (pszXML) + 1 ),
3336+ poBox->SetWritableData (static_cast <int >(strlen (pszXML)),
33373337 reinterpret_cast <const GByte *>(pszXML));
33383338 CPLFree (pszXML);
33393339
@@ -3362,7 +3362,7 @@ GDALJP2Box **GDALJP2Metadata::CreateXMLBoxes(GDALDataset *poSrcDS, int *pnBoxes)
33623362 GDALJP2Box *poBox = new GDALJP2Box ();
33633363 poBox->SetType (" xml " );
33643364 poBox->SetWritableData (
3365- static_cast <int >(strlen (*papszSrcMD) + 1 ),
3365+ static_cast <int >(strlen (*papszSrcMD)),
33663366 reinterpret_cast <const GByte *>(*papszSrcMD));
33673367 papoBoxes = static_cast <GDALJP2Box **>(CPLRealloc (
33683368 papoBoxes, sizeof (GDALJP2Box *) * (*pnBoxes + 1 )));
@@ -3385,7 +3385,7 @@ GDALJP2Box *GDALJP2Metadata::CreateXMPBox(GDALDataset *poSrcDS)
33853385 if (papszSrcMD && *papszSrcMD)
33863386 {
33873387 poBox = GDALJP2Box::CreateUUIDBox (
3388- xmp_uuid, static_cast <int >(strlen (*papszSrcMD) + 1 ),
3388+ xmp_uuid, static_cast <int >(strlen (*papszSrcMD)),
33893389 reinterpret_cast <const GByte *>(*papszSrcMD));
33903390 }
33913391 return poBox;
@@ -3403,7 +3403,7 @@ GDALJP2Box *GDALJP2Metadata::CreateIPRBox(GDALDataset *poSrcDS)
34033403 {
34043404 poBox = new GDALJP2Box ();
34053405 poBox->SetType (" jp2i" );
3406- poBox->SetWritableData (static_cast <int >(strlen (*papszSrcMD) + 1 ),
3406+ poBox->SetWritableData (static_cast <int >(strlen (*papszSrcMD)),
34073407 reinterpret_cast <const GByte *>(*papszSrcMD));
34083408 }
34093409 return poBox;
0 commit comments