summaryrefslogtreecommitdiff
path: root/libbb/last_char_is.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/last_char_is.c')
-rw-r--r--libbb/last_char_is.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libbb/last_char_is.c b/libbb/last_char_is.c
index a95e57c..4e2ee92 100644
--- a/libbb/last_char_is.c
+++ b/libbb/last_char_is.c
@@ -28,7 +28,10 @@
*/
char * last_char_is(const char *s, int c)
{
- char *sret = (char *)s+strlen(s)-1;
+ char *sret;
+ if (!s)
+ return NULL;
+ sret = (char *)s+strlen(s)-1;
if (sret>=s && *sret == c) {
return sret;
} else {