From e731205fd21eb8534d17fe10b7b1c45e414445a0 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Sun, 17 Feb 2013 15:19:03 -0500 Subject: [PATCH] Check for NULL before incrementing --- scripts/jlibtool.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/jlibtool.c b/scripts/jlibtool.c index 6ffaf4b..a34a5d5 100644 --- a/scripts/jlibtool.c +++ b/scripts/jlibtool.c @@ -969,7 +969,14 @@ static char *gen_library_name(const char *name, enum lib_type genlib) strcpy(newarg, name); } - newext = strrchr(newarg, '.') + 1; + newext = strrchr(newarg, '.'); + if (!newext) { + printf("Error: Library path does not have an extension"); + free(newarg); + + return NULL; + } + newext++; switch (genlib) { case type_STATIC_LIB: @@ -1076,13 +1083,14 @@ static char *check_library_exists(command_t *cmd, const char *arg, int pathlen, } strcpy(newarg + newpathlen, arg + pathlen); - ext = strrchr(newarg, '.') + 1; + ext = strrchr(newarg, '.'); if (!ext) { printf("Error: Library path does not have an extension"); free(newarg); return NULL; } + ext++; pass = 0; -- 2.1.4