mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-16 20:37:51 +01:00
Prevent zathura from SIGSEGV if link is a NULL pointer
This commit is contained in:
parent
adc9f41264
commit
ef99076a48
1 changed files with 20 additions and 16 deletions
|
@ -195,8 +195,10 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
|
||||||
|
|
||||||
if (priv->links_got == true && priv->links != NULL) {
|
if (priv->links_got == true && priv->links != NULL) {
|
||||||
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
|
if (link != NULL) {
|
||||||
redraw_rect(pageview, &rectangle);
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
|
||||||
|
redraw_rect(pageview, &rectangle);
|
||||||
|
}
|
||||||
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
|
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -340,22 +342,24 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
if (priv->draw_links == true && priv->number_of_links != 0) {
|
if (priv->draw_links == true && priv->number_of_links != 0) {
|
||||||
unsigned int link_counter = 0;
|
unsigned int link_counter = 0;
|
||||||
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
|
if (link != NULL) {
|
||||||
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
|
||||||
|
|
||||||
/* draw position */
|
/* draw position */
|
||||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
||||||
cairo_set_font_size(cairo, 10);
|
cairo_set_font_size(cairo, 10);
|
||||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
||||||
char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter);
|
char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter);
|
||||||
cairo_show_text(cairo, link_number);
|
cairo_show_text(cairo, link_number);
|
||||||
g_free(link_number);
|
g_free(link_number);
|
||||||
|
}
|
||||||
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
|
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue