[libbluray-devel] meta_parse: check realloc() return value
hpi1
git at videolan.org
Fri Oct 30 11:49:21 CET 2015
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Oct 7 12:57:29 2015 +0300| [2b6dec05f95f97d7a9dc79dede17594c0989ce5c] | committer: hpi1
meta_parse: check realloc() return value
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=2b6dec05f95f97d7a9dc79dede17594c0989ce5c
---
src/libbluray/bdnav/meta_parse.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/libbluray/bdnav/meta_parse.c b/src/libbluray/bdnav/meta_parse.c
index d7a7c6c..718ecd8 100644
--- a/src/libbluray/bdnav/meta_parse.c
+++ b/src/libbluray/bdnav/meta_parse.c
@@ -81,19 +81,24 @@ static void _parseManifestNode(xmlNode * a_node, META_DL *disclib)
}
else if (xmlStrEqual(cur_node->parent->name, BAD_CAST_CONST "tableOfContents")) {
if (xmlStrEqual(cur_node->name, BAD_CAST_CONST "titleName") && (tmp = xmlGetProp(cur_node, BAD_CAST_CONST "titleNumber"))) {
+ META_TITLE *new_entries = realloc(disclib->toc_entries, ((disclib->toc_count + 1)*sizeof(META_TITLE)));
+ if (new_entries) {
int i = disclib->toc_count;
disclib->toc_count++;
- disclib->toc_entries = realloc(disclib->toc_entries, (disclib->toc_count*sizeof(META_TITLE)));
+ disclib->toc_entries = new_entries;
disclib->toc_entries[i].title_number = atoi((const char*)tmp);
disclib->toc_entries[i].title_name = (char*)xmlNodeGetContent(cur_node);
+ }
XML_FREE(tmp);
}
}
else if (xmlStrEqual(cur_node->parent->name, BAD_CAST_CONST "description")) {
if (xmlStrEqual(cur_node->name, BAD_CAST_CONST "thumbnail") && (tmp = xmlGetProp(cur_node, BAD_CAST_CONST "href"))) {
+ META_THUMBNAIL *new_thumbnails = realloc(disclib->thumbnails, ((disclib->thumb_count + 1)*sizeof(META_THUMBNAIL)));
+ if (new_thumbnails) {
uint8_t i = disclib->thumb_count;
disclib->thumb_count++;
- disclib->thumbnails = realloc(disclib->thumbnails, (disclib->thumb_count*sizeof(META_THUMBNAIL)));
+ disclib->thumbnails = new_thumbnails;
disclib->thumbnails[i].path = (char *)tmp;
if ((tmp = xmlGetProp(cur_node, BAD_CAST_CONST "size"))) {
int x = 0, y = 0;
@@ -105,6 +110,7 @@ static void _parseManifestNode(xmlNode * a_node, META_DL *disclib)
else {
disclib->thumbnails[i].xres = disclib->thumbnails[i].yres = -1;
}
+ }
}
}
}
@@ -126,15 +132,18 @@ static void _findMetaXMLfiles(META_ROOT *meta, BD_DISC *disc)
if (ent.d_name[0] == '.')
continue;
else if (strncasecmp(ent.d_name, "bdmt_", 5) == 0) {
+ META_DL *new_dl_entries = realloc(meta->dl_entries, ((meta->dl_count + 1)*sizeof(META_DL)));
+ if (new_dl_entries) {
uint8_t i = meta->dl_count;
meta->dl_count++;
- meta->dl_entries = realloc(meta->dl_entries, (meta->dl_count*sizeof(META_DL)));
+ meta->dl_entries = new_dl_entries;
memset(&meta->dl_entries[i], 0, sizeof(meta->dl_entries[i]));
meta->dl_entries[i].filename = str_dup(ent.d_name);
strncpy(meta->dl_entries[i].language_code, ent.d_name+5,3);
meta->dl_entries[i].language_code[3] = '\0';
str_tolower(meta->dl_entries[i].language_code);
+ }
}
}
dir_close(dir);
More information about the libbluray-devel
mailing list