Fix memchr with a zero length.
The memchr implementation for 64 bit fails if these conditions occur: - The buffer is 32 byte aligned. - The buffer contains the character in the first byte. - The count sent in is zero. The function should return NULL, but it's not. Bug: 16676625 Change-Id: Iab33cc7a8b79920350c72f054dff0e0a3cde69ce
This commit is contained in:
@@ -75,6 +75,7 @@ ENTRY(memchr)
|
||||
* Magic constant 0x40100401 allows us to identify which lane matches
|
||||
* the requested byte.
|
||||
*/
|
||||
cbz cntin, .Lzero_length
|
||||
mov wtmp2, #0x0401
|
||||
movk wtmp2, #0x4010, lsl #16
|
||||
dup vrepchr.16b, chrin
|
||||
@@ -157,4 +158,8 @@ ENTRY(memchr)
|
||||
/* Select result or NULL */
|
||||
csel result, xzr, result, eq
|
||||
ret
|
||||
|
||||
.Lzero_length:
|
||||
mov result, xzr
|
||||
ret
|
||||
END(memchr)
|
||||
|
||||
Reference in New Issue
Block a user