Check for NULL returned by strrchr() and return error in that case.
It should not be reachable as the string should always contain a '/'
character, but follow best practices anyway.
Coverity CID:
1500356 Dereference null return value
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
char *t1, *t2;
t1 = strdup(cfname);
t2 = strrchr(t1, '/');
+ if (!t2)
+ return -EINVAL;
+
*t2 = '\0';
if (asprintf(&t2, "%s/settings", t1) == -1)