Overview
Comment: | Autorelease the return value of -[unicodeString] and include a BOM. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7b7250a0ba23ed28babc50daa5f5d468 |
User & Date: | js on 2011-05-01 23:58:26 |
Other Links: | manifest | tags |
Context
2011-05-02
| ||
13:01 | Don't free ret in -[unicodeString] as it is autoreleased now. check-in: 3a1cd610ed user: js tags: trunk | |
2011-05-01
| ||
23:58 | Autorelease the return value of -[unicodeString] and include a BOM. check-in: 7b7250a0ba user: js tags: trunk | |
23:42 | Fix a possible out-of-bounds read in -[OFString unicodeString]. check-in: 9d25dacab1 user: js tags: trunk | |
Changes
Modified src/OFString.h from [65a04abda1] to [1412423068].
︙ | ︙ | |||
512 513 514 515 516 517 518 | * OFInvalidEncodingException if the string contains any non-number characters. * * \return A double with the value of the string */ - (double)doubleValue; /** | | < > > > | | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | * OFInvalidEncodingException if the string contains any non-number characters. * * \return A double with the value of the string */ - (double)doubleValue; /** * Returns the string as an array of of_unichar_t. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * \return The string as an array of Unicode characters */ - (of_unichar_t*)unicodeString; /** * Writes the string into the specified file using UTF-8 encoding. |
︙ | ︙ |
Modified src/OFString.m from [f44982b7c8] to [fb7ee6732e].
︙ | ︙ | |||
1574 1575 1576 1577 1578 1579 1580 1581 | } return value; } - (of_unichar_t*)unicodeString { of_unichar_t *ret; | > | | > < < > > | | 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 | } return value; } - (of_unichar_t*)unicodeString { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; ret = [object allocMemoryForNItems: [self length] + 2 withSize: sizeof(of_unichar_t)]; i = 0; j = 0; ret[j++] = 0xFEFF; while (i < length) { of_unichar_t c; size_t cLen; cLen = of_string_utf8_to_unicode(string + i, length - i, &c); |
︙ | ︙ |
Modified tests/OFStringTests.m from [ae603ec4d9] to [24fef6ba66].
︙ | ︙ | |||
33 34 35 36 37 38 39 | #import "TestsAppDelegate.h" static OFString *module = @"OFString"; static OFString* whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; | | > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #import "TestsAppDelegate.h" static OFString *module = @"OFString"; static OFString* whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; static of_unichar_t ucstr[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0 }; static of_unichar_t sucstr[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100, 0 }; @interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate> @end |
︙ | ︙ | |||
366 367 368 369 370 371 372 | EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]", OFOutOfRangeException, [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) TEST(@"-[unicodeString]", (ua = [@"fööbär🀺" unicodeString]) && | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]", OFOutOfRangeException, [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) TEST(@"-[unicodeString]", (ua = [@"fööbär🀺" unicodeString]) && !memcmp(ua, ucstr, 9 * sizeof(of_unichar_t))) TEST(@"-[MD5Hash]", [[@"asdfoobar" MD5Hash] isEqual: @"184dce2ec49b5422c7cfd8728864db4c"]) TEST(@"-[SHA1Hash]", [[@"asdfoobar" SHA1Hash] isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"]) |
︙ | ︙ |