Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2014-08-19 14:44:44 +0400
committerRichard Earnshaw <rearnsha@arm.com>2014-08-19 14:44:44 +0400
commit59c3d5a1a4c0d8ee4f1da2c9e449ed9ab4edd4b6 (patch)
tree4c5a8a27bdb1d4223785c257a1b6e8ce49f17a22 /newlib/libc/machine
parentde1c312566d9d33b46e039505cc3d61b4de40b89 (diff)
* libc/machine/aarch64/memchr.S: Add check for zero-sized buffer.
Diffstat (limited to 'newlib/libc/machine')
-rw-r--r--newlib/libc/machine/aarch64/memchr.S6
1 files changed, 6 insertions, 0 deletions
diff --git a/newlib/libc/machine/aarch64/memchr.S b/newlib/libc/machine/aarch64/memchr.S
index eb59a5aad..53f5d6bc0 100644
--- a/newlib/libc/machine/aarch64/memchr.S
+++ b/newlib/libc/machine/aarch64/memchr.S
@@ -79,6 +79,8 @@
.endm
def_fn memchr
+ /* Do not dereference srcin if no bytes to compare. */
+ cbz cntin, .Lzero_length
/*
* Magic constant 0x40100401 allows us to identify which lane matches
* the requested byte.
@@ -166,5 +168,9 @@ def_fn memchr
csel result, xzr, result, eq
ret
+.Lzero_length:
+ mov result, #0
+ ret
+
.size memchr, . - memchr
#endif