This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 04/15/2011 01:09 PM, Eric Blake wrote:
> On 03/27/2011 09:37 PM, Yaakov (Cygwin/X) wrote:
>> I'm attaching a patch and new C file to implement strchrnul, a GNU
>> extension.
>>
>> Corinna: patch for winsup being posted to cygwin-patches.
>
>> char *
>> _DEFUN (strchrnul, (s1, i),
>> _CONST char *s1 _AND
>> int i)
>> {
>> char *s = strchr(s1, i);
>>
>> if (*s != NULL)
>
> Oops. That's a SEGV waiting to happen.
I'm pushing this:
2011-04-15 Eric Blake <eblake@redhat.com>
* libc/string/strchrnul.c (strchrnul): Fix strchrnul.
diff --git a/newlib/libc/string/strchrnul.c b/newlib/libc/string/strchrnul.c
index 59c7311..afeef43 100644
--- a/newlib/libc/string/strchrnul.c
+++ b/newlib/libc/string/strchrnul.c
@@ -43,7 +43,5 @@ _DEFUN (strchrnul, (s1, i),
{
char *s = strchr(s1, i);
- if (*s != NULL)
- return s;
- return (char *)s1 + strlen(s1);
+ return s ? s : (char *)s1 + strlen(s1);
}
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |