mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 23:26:00 +01:00
Correct usage of boolean values in sc_search
This patch resolves memory issues caused by using g_value_set_boolean and an incorrect type of the target variable. Thanks to edd@openbsd.org
This commit is contained in:
parent
10f3da57c6
commit
8d71a755d6
2 changed files with 14 additions and 12 deletions
|
@ -28,8 +28,8 @@ typedef struct zathura_page_widget_private_s {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
girara_list_t* list; /**< List of links on the page */
|
girara_list_t* list; /**< List of links on the page */
|
||||||
bool retrieved; /**< True if we already tried to retrieve the list of links */
|
gboolean retrieved; /**< True if we already tried to retrieve the list of links */
|
||||||
bool draw; /**< True if links should be drawn */
|
gboolean draw; /**< True if links should be drawn */
|
||||||
unsigned int offset; /**< Offset to the links */
|
unsigned int offset; /**< Offset to the links */
|
||||||
unsigned int n; /**< Number */
|
unsigned int n; /**< Number */
|
||||||
} links;
|
} links;
|
||||||
|
@ -37,12 +37,12 @@ typedef struct zathura_page_widget_private_s {
|
||||||
struct {
|
struct {
|
||||||
girara_list_t* list; /**< A list if there are search results that should be drawn */
|
girara_list_t* list; /**< A list if there are search results that should be drawn */
|
||||||
int current; /**< The index of the current search result */
|
int current; /**< The index of the current search result */
|
||||||
bool draw; /**< Draw search results */
|
gboolean draw; /**< Draw search results */
|
||||||
} search;
|
} search;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
girara_list_t* list; /**< List of images on the page */
|
girara_list_t* list; /**< List of images on the page */
|
||||||
bool retrieved; /**< True if we already tried to retrieve the list of images */
|
gboolean retrieved; /**< True if we already tried to retrieve the list of images */
|
||||||
zathura_image_t* current; /**< Image data of selected image */
|
zathura_image_t* current; /**< Image data of selected image */
|
||||||
} images;
|
} images;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ typedef struct zathura_page_widget_private_s {
|
||||||
int x; /**< X coordinate */
|
int x; /**< X coordinate */
|
||||||
int y; /**< Y coordinate */
|
int y; /**< Y coordinate */
|
||||||
} selection_basepoint;
|
} selection_basepoint;
|
||||||
bool over_link;
|
gboolean over_link;
|
||||||
} mouse;
|
} mouse;
|
||||||
} zathura_page_widget_private_t;
|
} zathura_page_widget_private_t;
|
||||||
|
|
||||||
|
@ -313,13 +313,13 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
|
||||||
case PROP_DRAW_LINKS:
|
case PROP_DRAW_LINKS:
|
||||||
priv->links.draw = g_value_get_boolean(value);
|
priv->links.draw = g_value_get_boolean(value);
|
||||||
/* get links */
|
/* get links */
|
||||||
if (priv->links.draw == true && priv->links.retrieved == false) {
|
if (priv->links.draw == TRUE && priv->links.retrieved == FALSE) {
|
||||||
priv->links.list = zathura_page_links_get(priv->page, NULL);
|
priv->links.list = zathura_page_links_get(priv->page, NULL);
|
||||||
priv->links.retrieved = true;
|
priv->links.retrieved = TRUE;
|
||||||
priv->links.n = (priv->links.list == NULL) ? 0 : girara_list_size(priv->links.list);
|
priv->links.n = (priv->links.list == NULL) ? 0 : girara_list_size(priv->links.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->links.retrieved == true && priv->links.list != NULL) {
|
if (priv->links.retrieved == TRUE && priv->links.list != NULL) {
|
||||||
GIRARA_LIST_FOREACH(priv->links.list, zathura_link_t*, iter, link)
|
GIRARA_LIST_FOREACH(priv->links.list, zathura_link_t*, iter, link)
|
||||||
if (link != NULL) {
|
if (link != NULL) {
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||||
|
@ -338,7 +338,7 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
|
||||||
}
|
}
|
||||||
priv->search.list = g_value_get_pointer(value);
|
priv->search.list = g_value_get_pointer(value);
|
||||||
if (priv->search.list != NULL && priv->search.draw) {
|
if (priv->search.list != NULL && priv->search.draw) {
|
||||||
priv->links.draw = false;
|
priv->links.draw = FALSE;
|
||||||
redraw_all_rects(pageview, priv->search.list);
|
redraw_all_rects(pageview, priv->search.list);
|
||||||
}
|
}
|
||||||
priv->search.current = -1;
|
priv->search.current = -1;
|
||||||
|
@ -355,7 +355,7 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
|
||||||
priv->search.current = girara_list_size(priv->search.list);
|
priv->search.current = girara_list_size(priv->search.list);
|
||||||
} else {
|
} else {
|
||||||
priv->search.current = val;
|
priv->search.current = val;
|
||||||
if (priv->search.draw == true && val >= 0 && val < (signed) girara_list_size(priv->search.list)) {
|
if (priv->search.draw == TRUE && val >= 0 && val < (signed) girara_list_size(priv->search.list)) {
|
||||||
zathura_rectangle_t* rect = girara_list_nth(priv->search.list, priv->search.current);
|
zathura_rectangle_t* rect = girara_list_nth(priv->search.list, priv->search.current);
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||||
redraw_rect(pageview, &rectangle);
|
redraw_rect(pageview, &rectangle);
|
||||||
|
|
|
@ -861,9 +861,11 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
|
||||||
const unsigned int num_pages = zathura_document_get_number_of_pages(zathura->document);
|
const unsigned int num_pages = zathura_document_get_number_of_pages(zathura->document);
|
||||||
const unsigned int cur_page = zathura_document_get_current_page_number(zathura->document);
|
const unsigned int cur_page = zathura_document_get_current_page_number(zathura->document);
|
||||||
GtkWidget *cur_page_widget = zathura_page_get_widget(zathura, zathura_document_get_page(zathura->document, cur_page));
|
GtkWidget *cur_page_widget = zathura_page_get_widget(zathura, zathura_document_get_page(zathura->document, cur_page));
|
||||||
bool nohlsearch, first_time_after_abort, draw;
|
bool nohlsearch, first_time_after_abort;
|
||||||
|
gboolean draw;
|
||||||
|
|
||||||
nohlsearch = first_time_after_abort = draw = false;
|
nohlsearch = first_time_after_abort = false;
|
||||||
|
draw = FALSE;
|
||||||
girara_setting_get(session, "nohlsearch", &nohlsearch);
|
girara_setting_get(session, "nohlsearch", &nohlsearch);
|
||||||
|
|
||||||
if (nohlsearch == false) {
|
if (nohlsearch == false) {
|
||||||
|
|
Loading…
Reference in a new issue