@@ -248,9 +248,10 @@ _internal_toASCII(const char16_t* src, int32_t srcLength,
248
248
if (srcIsASCII == false ){
249
249
250
250
// step 2
251
- b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, status);
251
+ UErrorCode bufferStatus = U_ZERO_ERROR;
252
+ b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, &bufferStatus);
252
253
253
- if (*status == U_BUFFER_OVERFLOW_ERROR){
254
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
254
255
// redo processing of string
255
256
// we do not have enough room so grow the buffer
256
257
if (b1 != b1Stack){
@@ -262,9 +263,12 @@ _internal_toASCII(const char16_t* src, int32_t srcLength,
262
263
goto CLEANUP;
263
264
}
264
265
265
- *status = U_ZERO_ERROR; // reset error
266
-
267
- b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, status);
266
+ bufferStatus = U_ZERO_ERROR; // reset error
267
+
268
+ b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, &bufferStatus);
269
+ }
270
+ if (U_FAILURE (bufferStatus)) {
271
+ *status = bufferStatus;
268
272
}
269
273
}
270
274
// error bail out
@@ -333,9 +337,10 @@ _internal_toASCII(const char16_t* src, int32_t srcLength,
333
337
// caseFlags = (UBool*) uprv_malloc(b1Len * sizeof(UBool));
334
338
// uprv_memset(caseFlags,true,b1Len);
335
339
336
- b2Len = u_strToPunycode (b1,b1Len,b2,b2Capacity,caseFlags, status);
340
+ UErrorCode bufferStatus = U_ZERO_ERROR;
341
+ b2Len = u_strToPunycode (b1,b1Len,b2,b2Capacity,caseFlags,&bufferStatus);
337
342
338
- if (*status == U_BUFFER_OVERFLOW_ERROR){
343
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
339
344
// redo processing of string
340
345
/* we do not have enough room so grow the buffer*/
341
346
b2 = static_cast <char16_t *>(uprv_malloc (b2Len * U_SIZEOF_UCHAR));
@@ -344,12 +349,13 @@ _internal_toASCII(const char16_t* src, int32_t srcLength,
344
349
goto CLEANUP;
345
350
}
346
351
347
- *status = U_ZERO_ERROR; // reset error
348
-
349
- b2Len = u_strToPunycode (b1,b1Len,b2,b2Len,caseFlags, status );
352
+ bufferStatus = U_ZERO_ERROR; // reset error
353
+
354
+ b2Len = u_strToPunycode (b1,b1Len,b2,b2Len,caseFlags,&bufferStatus );
350
355
}
351
356
// error bail out
352
- if (U_FAILURE (*status)){
357
+ if (U_FAILURE (bufferStatus)){
358
+ *status = bufferStatus;
353
359
goto CLEANUP;
354
360
}
355
361
// TODO : Reconsider while implementing the case preserve RFE
@@ -454,8 +460,9 @@ _internal_toUnicode(const char16_t* src, int32_t srcLength,
454
460
455
461
if (srcIsASCII == false ){
456
462
// step 2: process the string
457
- b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, status);
458
- if (*status == U_BUFFER_OVERFLOW_ERROR){
463
+ UErrorCode bufferStatus = U_ZERO_ERROR;
464
+ b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Capacity, namePrepOptions, parseError, &bufferStatus);
465
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
459
466
// redo processing of string
460
467
/* we do not have enough room so grow the buffer*/
461
468
b1 = static_cast <char16_t *>(uprv_malloc (b1Len * U_SIZEOF_UCHAR));
@@ -464,12 +471,13 @@ _internal_toUnicode(const char16_t* src, int32_t srcLength,
464
471
goto CLEANUP;
465
472
}
466
473
467
- *status = U_ZERO_ERROR; // reset error
468
-
469
- b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, status );
474
+ bufferStatus = U_ZERO_ERROR; // reset error
475
+
476
+ b1Len = usprep_prepare (nameprep, src, srcLength, b1, b1Len, namePrepOptions, parseError, &bufferStatus );
470
477
}
471
478
// bail out on error
472
- if (U_FAILURE (*status)){
479
+ if (U_FAILURE (bufferStatus)){
480
+ *status = bufferStatus;
473
481
goto CLEANUP;
474
482
}
475
483
}else {
@@ -493,9 +501,10 @@ _internal_toUnicode(const char16_t* src, int32_t srcLength,
493
501
b1PrimeLen = b1Len - ACE_PREFIX_LENGTH;
494
502
495
503
// step 5: Decode using punycode
496
- b2Len = u_strFromPunycode (b1Prime, b1PrimeLen, b2, b2Capacity, caseFlags,status);
504
+ UErrorCode bufferStatus = U_ZERO_ERROR;
505
+ b2Len = u_strFromPunycode (b1Prime, b1PrimeLen, b2, b2Capacity, caseFlags, &bufferStatus);
497
506
498
- if (*status == U_BUFFER_OVERFLOW_ERROR){
507
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
499
508
// redo processing of string
500
509
/* we do not have enough room so grow the buffer*/
501
510
b2 = static_cast <char16_t *>(uprv_malloc (b2Len * U_SIZEOF_UCHAR));
@@ -504,16 +513,16 @@ _internal_toUnicode(const char16_t* src, int32_t srcLength,
504
513
goto CLEANUP;
505
514
}
506
515
507
- *status = U_ZERO_ERROR; // reset error
516
+ bufferStatus = U_ZERO_ERROR; // reset error
508
517
509
- b2Len = u_strFromPunycode (b1Prime, b1PrimeLen, b2, b2Len, caseFlags, status );
518
+ b2Len = u_strFromPunycode (b1Prime, b1PrimeLen, b2, b2Len, caseFlags, &bufferStatus );
510
519
}
511
520
512
521
513
522
// step 6:Apply toASCII
514
- b3Len = uidna_toASCII (b2, b2Len, b3, b3Capacity, options, parseError, status );
523
+ b3Len = uidna_toASCII (b2, b2Len, b3, b3Capacity, options, parseError, &bufferStatus );
515
524
516
- if (*status == U_BUFFER_OVERFLOW_ERROR){
525
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
517
526
// redo processing of string
518
527
/* we do not have enough room so grow the buffer*/
519
528
b3 = static_cast <char16_t *>(uprv_malloc (b3Len * U_SIZEOF_UCHAR));
@@ -522,13 +531,14 @@ _internal_toUnicode(const char16_t* src, int32_t srcLength,
522
531
goto CLEANUP;
523
532
}
524
533
525
- *status = U_ZERO_ERROR; // reset error
534
+ bufferStatus = U_ZERO_ERROR; // reset error
526
535
527
- b3Len = uidna_toASCII (b2,b2Len,b3,b3Len,options,parseError, status );
536
+ b3Len = uidna_toASCII (b2,b2Len,b3,b3Len,options,parseError,&bufferStatus );
528
537
529
538
}
530
539
// bail out on error
531
- if (U_FAILURE (*status)){
540
+ if (U_FAILURE (bufferStatus)){
541
+ *status = bufferStatus;
532
542
goto CLEANUP;
533
543
}
534
544
@@ -706,24 +716,21 @@ uidna_IDNToASCII( const char16_t *src, int32_t srcLength,
706
716
labelLen = getNextSeparator (labelStart,remainingLen, &delimiter,&done);
707
717
labelReqLength = 0 ;
708
718
if (!(labelLen==0 && done)){// make sure this is not a root label separator.
709
-
710
- labelReqLength = _internal_toASCII ( labelStart, labelLen,
711
- currentDest, remainingDestCapacity,
712
- options, nameprep,
713
- parseError, status);
714
-
715
- if (*status == U_BUFFER_OVERFLOW_ERROR){
716
-
717
- *status = U_ZERO_ERROR; // reset error
719
+
720
+ UErrorCode bufferStatus = U_ZERO_ERROR;
721
+ labelReqLength = _internal_toASCII ( labelStart, labelLen,
722
+ currentDest, remainingDestCapacity,
723
+ options, nameprep,
724
+ parseError, &bufferStatus);
725
+
726
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR) {
718
727
remainingDestCapacity = 0 ;
728
+ } else if (U_FAILURE (bufferStatus)) {
729
+ *status = bufferStatus;
730
+ break ;
719
731
}
720
732
}
721
733
722
-
723
- if (U_FAILURE (*status)){
724
- break ;
725
- }
726
-
727
734
reqLength +=labelReqLength;
728
735
// adjust the destination pointer
729
736
if (labelReqLength < remainingDestCapacity){
@@ -877,35 +884,39 @@ uidna_compare( const char16_t *s1, int32_t length1,
877
884
878
885
UParseError parseError;
879
886
880
- b1Len = uidna_IDNToASCII (s1, length1, b1, b1Capacity, options, &parseError, status);
881
- if (*status == U_BUFFER_OVERFLOW_ERROR){
887
+ UErrorCode bufferStatus = U_ZERO_ERROR;
888
+ b1Len = uidna_IDNToASCII (s1, length1, b1, b1Capacity, options, &parseError, &bufferStatus);
889
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
882
890
// redo processing of string
883
891
b1 = (char16_t *) uprv_malloc (b1Len * U_SIZEOF_UCHAR);
884
892
if (b1==nullptr ){
885
893
*status = U_MEMORY_ALLOCATION_ERROR;
886
894
goto CLEANUP;
887
895
}
888
896
889
- *status = U_ZERO_ERROR; // reset error
890
-
891
- b1Len = uidna_IDNToASCII (s1,length1,b1,b1Len, options, &parseError, status);
892
-
897
+ bufferStatus = U_ZERO_ERROR; // reset error
898
+
899
+ b1Len = uidna_IDNToASCII (s1,length1,b1,b1Len, options, &parseError, &bufferStatus);
893
900
}
894
901
895
- b2Len = uidna_IDNToASCII (s2,length2, b2,b2Capacity, options, &parseError, status );
896
- if (*status == U_BUFFER_OVERFLOW_ERROR){
902
+ b2Len = uidna_IDNToASCII (s2,length2, b2,b2Capacity, options, &parseError, &bufferStatus );
903
+ if (bufferStatus == U_BUFFER_OVERFLOW_ERROR){
897
904
// redo processing of string
898
905
b2 = (char16_t *) uprv_malloc (b2Len * U_SIZEOF_UCHAR);
899
906
if (b2==nullptr ){
900
907
*status = U_MEMORY_ALLOCATION_ERROR;
901
908
goto CLEANUP;
902
909
}
903
910
904
- *status = U_ZERO_ERROR; // reset error
905
-
906
- b2Len = uidna_IDNToASCII (s2, length2, b2, b2Len, options, &parseError, status);
907
-
911
+ bufferStatus = U_ZERO_ERROR; // reset error
912
+
913
+ b2Len = uidna_IDNToASCII (s2, length2, b2, b2Len, options, &parseError, &bufferStatus);
914
+ }
915
+
916
+ if (U_FAILURE (bufferStatus)) {
917
+ *status = bufferStatus;
908
918
}
919
+
909
920
// when toASCII is applied all label separators are replaced with FULL_STOP
910
921
result = compareCaseInsensitiveASCII (b1,b1Len,b2,b2Len);
911
922
0 commit comments