]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/ucnv2022.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / common / ucnv2022.cpp
index d1a50d269f1b24bfd481b9dabc4d79c0616c1756..dbc5bb7e07b2d6e18d6b46bdd088a7dd3ade4c25 100644 (file)
@@ -3571,20 +3571,11 @@ _ISO_2022_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorC
 
 /*
  * Structure for cloning an ISO 2022 converter into a single memory block.
- * ucnv_safeClone() of the converter will align the entire cloneStruct,
- * and then ucnv_safeClone() of the sub-converter may additionally align
- * currentConverter inside the cloneStruct, for which we need the deadSpace
- * after currentConverter.
- * This is because UAlignedMemory may be larger than the actually
- * necessary alignment size for the platform.
- * The other cloneStruct fields will not be moved around,
- * and are aligned properly with cloneStruct's alignment.
  */
 struct cloneStruct
 {
     UConverter cnv;
     UConverter currentConverter;
-    UAlignedMemory deadSpace;
     UConverterDataISO2022 mydata;
 };
 
@@ -3602,6 +3593,10 @@ _ISO_2022_SafeClone(
     UConverterDataISO2022 *cnvData;
     int32_t i, size;
 
+    if (U_FAILURE(*status)){
+        return nullptr;
+    }
+
     if (*pBufferSize == 0) { /* 'preflighting' request - set needed size into *pBufferSize */
         *pBufferSize = (int32_t)sizeof(struct cloneStruct);
         return NULL;
@@ -3619,7 +3614,7 @@ _ISO_2022_SafeClone(
     /* share the subconverters */
 
     if(cnvData->currentConverter != NULL) {
-        size = (int32_t)(sizeof(UConverter) + sizeof(UAlignedMemory)); /* include size of padding */
+        size = (int32_t)sizeof(UConverter);
         localClone->mydata.currentConverter =
             ucnv_safeClone(cnvData->currentConverter,
                             &localClone->currentConverter,