Home | History | Annotate | Download | only in patches
      1 Index: test/cintltst/utexttst.c
      2 ===================================================================
      3 --- test/cintltst/utexttst.c	(revision 29355)
      4 +++ test/cintltst/utexttst.c	(revision 29356)
      5 @@ -1,6 +1,6 @@
      6  /********************************************************************
      7   * COPYRIGHT: 
      8 - * Copyright (c) 2005-2009, International Business Machines Corporation and
      9 + * Copyright (c) 2005-2011, International Business Machines Corporation and
     10   * others. All Rights Reserved.
     11   ********************************************************************/
     12  /*
     13 @@ -210,6 +210,10 @@
     14          UChar     uString[]  = {0x41, 0x42, 0x43, 0};
     15          UChar     buf[100];
     16          int32_t   i;
     17 +        /* Test pinning of input bounds */
     18 +        UChar     uString2[]  = {0x41, 0x42, 0x43, 0x44, 0x45,
     19 +                                 0x46, 0x47, 0x48, 0x49, 0x4A, 0};
     20 +        UChar *   uString2Ptr = uString2 + 5;
     21  
     22          status = U_ZERO_ERROR;
     23          uta = utext_openUChars(NULL, uString, -1, &status);
     24 @@ -228,6 +232,20 @@
     25          i = u_strcmp(uString, buf);
     26          TEST_ASSERT(i == 0);
     27          utext_close(uta);
     28 +
     29 +        /* Test pinning of input bounds */
     30 +        status = U_ZERO_ERROR;
     31 +        uta = utext_openUChars(NULL, uString2Ptr, -1, &status);
     32 +        TEST_SUCCESS(status);
     33 +
     34 +        status = U_ZERO_ERROR;
     35 +        memset(buf, 0, sizeof(buf));
     36 +        i = utext_extract(uta, -3, 20, buf, 100, &status);
     37 +        TEST_SUCCESS(status);
     38 +        TEST_ASSERT(i == u_strlen(uString2Ptr));
     39 +        i = u_strcmp(uString2Ptr, buf);
     40 +        TEST_ASSERT(i == 0);
     41 +        utext_close(uta);
     42      }
     43  
     44      {
     45 Index: common/utext.cpp
     46 ===================================================================
     47 --- common/utext.cpp	(revision 29355)
     48 +++ common/utext.cpp	(revision 29356)
     49 @@ -1,7 +1,7 @@
     50  /*
     51  *******************************************************************************
     52  *
     53 -*   Copyright (C) 2005-2010, International Business Machines
     54 +*   Copyright (C) 2005-2011, International Business Machines
     55  *   Corporation and others.  All Rights Reserved.
     56  *
     57  *******************************************************************************
     58 @@ -2846,7 +2846,6 @@
     59          return 0;
     60      }
     61  
     62 -    const UChar *s=(const UChar *)ut->context;
     63      int32_t si, di;
     64  
     65      int32_t start32;
     66 @@ -2856,8 +2855,8 @@
     67      //   Pins 'start' to the length of the string, if it came in out-of-bounds.
     68      //   Snaps 'start' to the beginning of a code point.
     69      ucstrTextAccess(ut, start, TRUE);
     70 -    U_ASSERT(start <= INT32_MAX);
     71 -    start32 = (int32_t)start;
     72 +    const UChar *s=ut->chunkContents;
     73 +    start32 = ut->chunkOffset;
     74  
     75      int32_t strLength=(int32_t)ut->a;
     76      if (strLength >= 0) {
     77