From 08fdddea3d2a170f5476ad296d9b73bcf2948471 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 24 Mar 2016 10:06:50 +0100 Subject: [PATCH] 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 --- 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 35ad3bd13..27900c289 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;