This is the mail archive of the newlib-cvs@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]

[newlib-cygwin] Fix coverity CID 143502: Null pointer dereference


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=08fdddea3d2a170f5476ad296d9b73bcf2948471

commit 08fdddea3d2a170f5476ad296d9b73bcf2948471
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Mar 24 10:06:50 2016 +0100

    Fix coverity CID 143502: Null pointer dereference
    
    	* libc/locale/ldpart.c (split_lines): Don't dereference result
    	of strchr without checking for NULL pointer first.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/locale/ldpart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newlib/libc/locale/ldpart.c b/newlib/libc/locale/ldpart.c
index 35ad3bd..27900c2 100644
--- a/newlib/libc/locale/ldpart.c
+++ b/newlib/libc/locale/ldpart.c
@@ -175,6 +175,8 @@ split_lines(char *p, const char *plim) {
 
 	for (i = 0; p < plim; i++) {
 		p = strchr(p, '\n');
+		if (!p)
+			break;
 		*p++ = '\0';
 	}
 	return i;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]