Commit a508631b authored by Petri Hintukainen's avatar Petri Hintukainen

disc: check memory allocations

parent 8bb56b3a
......@@ -108,6 +108,9 @@ static void *_open_libaacs(void)
BD_AACS *libaacs_load(void)
{
BD_AACS *p = calloc(1, sizeof(BD_AACS));
if (!p) {
return NULL;
}
p->h_libaacs = _open_libaacs();
if (!p->h_libaacs) {
......
......@@ -107,6 +107,9 @@ static void *_libbdplus_open(void)
BD_BDPLUS *libbdplus_load(void)
{
BD_BDPLUS *p = calloc(1, sizeof(BD_BDPLUS));
if (!p) {
return NULL;
}
BD_DEBUG(DBG_BDPLUS, "attempting to load libbdplus\n");
......@@ -241,10 +244,12 @@ BD_BDPLUS_ST *libbdplus_m2ts(BD_BDPLUS *p, uint32_t clip_id, uint64_t pos)
if (!p->m2ts) {
/* use old API */
BD_BDPLUS_ST *ret = calloc(1, sizeof(BD_BDPLUS_ST));
if (ret) {
ret->lib = p;
ret->st = NULL;
p->title(p->bdplus, clip_id);
p->seek(p->bdplus, pos);
}
return ret;
}
......@@ -258,9 +263,11 @@ BD_BDPLUS_ST *libbdplus_m2ts(BD_BDPLUS *p, uint32_t clip_id, uint64_t pos)
p->m2ts_close(st);
} else {
BD_BDPLUS_ST *ret = calloc(1, sizeof(BD_BDPLUS_ST));
if (ret) {
ret->lib = p;
ret->st = st;
BD_DEBUG(DBG_BLURAY | DBG_CRIT, "BD+ active for clip %05d.m2ts\n", clip_id);
}
return ret;
}
}
......
......@@ -158,6 +158,10 @@ static int _bdrom_have_file(void *p, const char *dir, const char *file)
char *path;
path = str_printf("%s" DIR_SEP "%s", dir, file);
if (!path) {
return 0;
}
fp = dev->pf_file_open_bdrom(dev->file_open_bdrom_handle, path);
X_FREE(path);
......
......@@ -65,6 +65,10 @@ static BD_FILE_H *_bdrom_open_path(void *p, const char *rel_path)
char *abs_path;
abs_path = str_printf("%s%s", disc->disc_root, rel_path);
if (!abs_path) {
return NULL;
}
fp = file_open(abs_path, "rb");
X_FREE(abs_path);
......@@ -78,6 +82,10 @@ static BD_DIR_H *_bdrom_open_dir(void *p, const char *dir)
char *path;
path = str_printf("%s%s", disc->disc_root, dir);
if (!path) {
return NULL;
}
dp = dir_open(path);
X_FREE(path);
......@@ -96,9 +104,11 @@ static BD_FILE_H *_overlay_open_path(BD_DISC *p, const char *rel_path)
if (p->overlay_root) {
char *abs_path = str_printf("%s%s", p->overlay_root, rel_path);
if (abs_path) {
fp = file_open(abs_path, "rb");
X_FREE(abs_path);
}
}
bd_mutex_unlock(&p->ovl_mutex);
......@@ -113,9 +123,11 @@ static BD_DIR_H *_overlay_open_dir(BD_DISC *p, const char *dir)
if (p->overlay_root) {
char *abs_path = str_printf("%s%s", p->disc_root, dir);
if (abs_path) {
dp = dir_open_default()(abs_path);
X_FREE(abs_path);
}
}
bd_mutex_unlock(&p->ovl_mutex);
......@@ -183,6 +195,10 @@ static BD_DIR_H *_combine_dirs(BD_DIR_H *ovl, BD_DIR_H *rom)
dp->read = _comb_dir_read;
dp->close = _comb_dir_close;
dp->internal = calloc(1, sizeof(COMB_DIR));
if (!dp->internal) {
X_FREE(dp);
goto out;
}
while (!dir_read(ovl, &entry)) {
_comb_dir_append(dp, &entry);
......@@ -191,6 +207,8 @@ static BD_DIR_H *_combine_dirs(BD_DIR_H *ovl, BD_DIR_H *rom)
_comb_dir_append(dp, &entry);
}
}
out:
dir_close(ovl);
dir_close(rom);
......@@ -342,6 +360,10 @@ BD_FILE_H *disc_open_file(BD_DISC *p, const char *dir, const char *file)
char *path;
path = str_printf("%s" DIR_SEP "%s", dir, file);
if (!path) {
return NULL;
}
fp = disc_open_path(p, path);
X_FREE(path);
......
......@@ -67,6 +67,9 @@ static int64_t _file_read(BD_FILE_H *file, uint8_t *buf, int64_t size)
BD_FILE_H *udf_file_open(void *udf, const char *filename)
{
BD_FILE_H *file = calloc(1, sizeof(BD_FILE_H));
if (!file) {
return NULL;
}
BD_DEBUG(DBG_FILE, "Opening UDF file %s... (%p)\n", filename, (void*)file);
......@@ -116,6 +119,9 @@ static int _dir_read(BD_DIR_H *dir, BD_DIRENT *entry)
BD_DIR_H *udf_dir_open(void *udf, const char* dirname)
{
BD_DIR_H *dir = calloc(1, sizeof(BD_DIR_H));
if (!dir) {
return NULL;
}
BD_DEBUG(DBG_DIR, "Opening UDF dir %s... (%p)\n", dirname, (void*)dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment