Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 6626:b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Found with UndefinedBehaviorSanitizer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 07 Jul 2016 21:02:28 +0300 |
parents | fcbac620ae83 |
children | 289403abc84e 5c25f01bbd52 |
comparison
equal
deleted
inserted
replaced
6625:a616bdc38645 | 6626:b3682580c1bd |
---|---|
1561 /* find the number of the characters to be escaped */ | 1561 /* find the number of the characters to be escaped */ |
1562 | 1562 |
1563 n = 0; | 1563 n = 0; |
1564 | 1564 |
1565 while (size) { | 1565 while (size) { |
1566 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { | 1566 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
1567 n++; | 1567 n++; |
1568 } | 1568 } |
1569 src++; | 1569 src++; |
1570 size--; | 1570 size--; |
1571 } | 1571 } |
1572 | 1572 |
1573 return (uintptr_t) n; | 1573 return (uintptr_t) n; |
1574 } | 1574 } |
1575 | 1575 |
1576 while (size) { | 1576 while (size) { |
1577 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { | 1577 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
1578 *dst++ = '%'; | 1578 *dst++ = '%'; |
1579 *dst++ = hex[*src >> 4]; | 1579 *dst++ = hex[*src >> 4]; |
1580 *dst++ = hex[*src & 0xf]; | 1580 *dst++ = hex[*src & 0xf]; |
1581 src++; | 1581 src++; |
1582 | 1582 |