[libbluray-devel] mpls_dump: check allocs
hpi1
git at videolan.org
Sun Aug 21 15:06:49 CEST 2016
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Aug 21 15:45:02 2016 +0300| [0d187b53540698a824396b1495004c88c8fb511a] | committer: hpi1
mpls_dump: check allocs
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=0d187b53540698a824396b1495004c88c8fb511a
---
src/devtools/mpls_dump.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/devtools/mpls_dump.c b/src/devtools/mpls_dump.c
index de7da0e..547b947 100644
--- a/src/devtools/mpls_dump.c
+++ b/src/devtools/mpls_dump.c
@@ -160,10 +160,11 @@ _mk_path(const char *base, const char *sub)
size_t n1 = strlen(base);
size_t n2 = strlen(sub);
char *result = (char*)malloc(n1 + n2 + strlen(DIR_SEP) + 1);
- strcpy(result, base);
- strcat(result, DIR_SEP);
- strcat(result, sub);
-
+ if (result) {
+ strcpy(result, base);
+ strcat(result, DIR_SEP);
+ strcat(result, sub);
+ }
return result;
}
@@ -762,6 +763,9 @@ main(int argc, char *argv[])
}
if (dir != NULL) {
char **dirlist = (char**)calloc(10001, sizeof(char*));
+ if (!dirlist) {
+ continue;
+ }
struct dirent *ent;
int jj = 0;
for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
@@ -771,6 +775,9 @@ main(int argc, char *argv[])
for (jj = 0; dirlist[jj] != NULL && pl_ii < 1000; jj++) {
char *name = NULL;
name = _mk_path(path, dirlist[jj]);
+ if (name == NULL) {
+ continue;
+ }
free(dirlist[jj]);
if (stat(name, &st)) {
free(name);
More information about the libbluray-devel
mailing list