[geany/geany-plugins] df0853: debugger: Avoid potential NULL dereference
Colomban Wendling
git-noreply at xxxxx
Sun Feb 7 13:55:30 UTC 2016
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 07 Feb 2016 13:55:30 UTC
Commit: df085357945afecd087736db837f63b07ddc94ad
https://github.com/geany/geany-plugins/commit/df085357945afecd087736db837f63b07ddc94ad
Log Message:
-----------
debugger: Avoid potential NULL dereference
It shouldn't be possible the code references a frame off the end of the
list, but better safe than sorry.
Modified Paths:
--------------
debugger/src/debug.c
Modified: debugger/src/debug.c
18 lines changed, 12 insertions(+), 6 deletions(-)
===================================================================
@@ -930,9 +930,12 @@ dbg_callbacks callbacks = {
static void on_select_frame(int frame_number)
{
GList *autos, *watches;
- frame *f = (frame*)g_list_nth(stack, active_module->get_active_frame())->data;
- markers_remove_current_instruction(f->file, f->line);
- markers_add_frame(f->file, f->line);
+ frame *f = (frame*)g_list_nth_data(stack, active_module->get_active_frame());
+ if (f)
+ {
+ markers_remove_current_instruction(f->file, f->line);
+ markers_add_frame(f->file, f->line);
+ }
active_module->set_active_frame(frame_number);
@@ -948,9 +951,12 @@ static void on_select_frame(int frame_number)
watches = active_module->get_watches();
update_variables(GTK_TREE_VIEW(wtree), NULL, watches);
- f = (frame*)g_list_nth(stack, frame_number)->data;
- markers_remove_frame(f->file, f->line);
- markers_add_current_instruction(f->file, f->line);
+ f = (frame*)g_list_nth_data(stack, frame_number);
+ if (f)
+ {
+ markers_remove_frame(f->file, f->line);
+ markers_add_current_instruction(f->file, f->line);
+ }
}
/*
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list