diff options
author | Alan Somers <asomers@FreeBSD.org> | 2017-12-06 23:24:11 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2017-12-06 23:24:11 +0000 |
commit | 0812ee3af2c3db3ac5fd6ad34ffd39ffc718eb93 (patch) | |
tree | 0dec45e70a3894c365c1620ff613957f6213e608 /lib/libcam | |
parent | 762a7f4f5f6f643c1c871554795ab9544cadc3a5 (diff) | |
download | src-0812ee3af2c3db3ac5fd6ad34ffd39ffc718eb93.tar.gz src-0812ee3af2c3db3ac5fd6ad34ffd39ffc718eb93.zip |
Notes
Diffstat (limited to 'lib/libcam')
-rw-r--r-- | lib/libcam/camlib.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c index 1f221456ca23..40242958bfaf 100644 --- a/lib/libcam/camlib.c +++ b/lib/libcam/camlib.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/param.h> +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -132,6 +133,9 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit) * it so we don't hose the user's string. */ newpath = (char *)strdup(path); + if (newpath == NULL) + return (-1); + tmpstr = newpath; /* @@ -140,8 +144,9 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit) if (*tmpstr == '/') { tmpstr2 = tmpstr; tmpstr = strrchr(tmpstr2, '/'); - if ((tmpstr != NULL) && (*tmpstr != '\0')) - tmpstr++; + /* We know that tmpstr2 contains a '/', so strrchr can't fail */ + assert(tmpstr != NULL && *tmpstr != '\0'); + tmpstr++; } if (*tmpstr == '\0') { |