[libbluray-devel] Check for NULL
hpi1
git at videolan.org
Mon Aug 25 10:21:35 CEST 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Aug 25 11:14:48 2014 +0300| [8d7b9b33290ecbcf9947a7bca345eb1d17861296] | committer: hpi1
Check for NULL
Protect against (theoretical) NULL pointer dereference.
None of the checks are triggered with current code, but might be in future.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=8d7b9b33290ecbcf9947a7bca345eb1d17861296
---
src/libbluray/decoders/graphics_controller.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/libbluray/decoders/graphics_controller.c b/src/libbluray/decoders/graphics_controller.c
index 9474c9d..85acd23 100644
--- a/src/libbluray/decoders/graphics_controller.c
+++ b/src/libbluray/decoders/graphics_controller.c
@@ -1005,9 +1005,11 @@ static int _render_textst(GRAPHICS_CONTROLLER *p, uint32_t stc, GC_NAV_CMDS *cmd
/* next dialog too far in future ? */
if (now < 1 || dialog[ii].start_pts >= now + 90000) {
- cmds->wakeup_time = dialog[ii].start_pts / 2;
GC_TRACE("_render_textst(): next event #%d in %"PRId64" seconds (pts %"PRId64")\n",
ii, (dialog[ii].start_pts - now)/90000, dialog[ii].start_pts);
+ if (cmds) {
+ cmds->wakeup_time = dialog[ii].start_pts / 2;
+ }
return 1;
}
@@ -1458,11 +1460,13 @@ static int _render_page(GRAPHICS_CONTROLLER *gc,
/* do not trigger auto action before single-loop animations have been terminated */
if (gc->button_effect_running) {
GC_TRACE(" auto-activate #%d not triggered (ANIMATING)\n", auto_activate_button->id);
- } else {
+ } else if (cmds) {
cmds->num_nav_cmds = auto_activate_button->num_nav_cmds;
cmds->nav_cmds = auto_activate_button->nav_cmds;
gc->auto_action_triggered = 1;
+ } else {
+ GC_ERROR("_render_page(): auto-activate ignored (missing result buffer)\n");
}
}
@@ -1565,9 +1569,13 @@ static int _user_input(GRAPHICS_CONTROLLER *gc, uint32_t key, GC_NAV_CMDS *cmds)
case BD_VK_ENTER:
activated_btn_id = cur_btn_id;
- cmds->num_nav_cmds = button->num_nav_cmds;
- cmds->nav_cmds = button->nav_cmds;
- cmds->sound_id_ref = button->activated_sound_id_ref;
+ if (cmds) {
+ cmds->num_nav_cmds = button->num_nav_cmds;
+ cmds->nav_cmds = button->nav_cmds;
+ cmds->sound_id_ref = button->activated_sound_id_ref;
+ } else {
+ GC_ERROR("_user_input(): VD_VK_ENTER action ignored (missing result buffer)\n");
+ }
break;
default:;
}
@@ -1575,7 +1583,7 @@ static int _user_input(GRAPHICS_CONTROLLER *gc, uint32_t key, GC_NAV_CMDS *cmds)
if (new_btn_id != cur_btn_id) {
BD_IG_BUTTON *new_button = _find_button_page(page, new_btn_id, NULL);
- if (new_button) {
+ if (new_button && cmds) {
cmds->sound_id_ref = new_button->selected_sound_id_ref;
}
}
More information about the libbluray-devel
mailing list