5246fc
--- evince-3.28.2/backend/comics/comics-document.c
5246fc
+++ evince-3.28.2/backend/comics/comics-document.c
5246fc
@@ -453,23 +453,27 @@ comics_document_render_pixbuf (EvDocumen
5246fc
 
5246fc
 		name = ev_archive_get_entry_pathname (comics_document->archive);
5246fc
 		if (g_strcmp0 (name, page_path) == 0) {
5246fc
-			size_t size = ev_archive_get_entry_size (comics_document->archive);
5246fc
+			gint64 size = ev_archive_get_entry_size (comics_document->archive);
5246fc
 			char *buf;
5246fc
 			ssize_t read;
5246fc
 
5246fc
-			buf = g_malloc (size);
5246fc
-			read = ev_archive_read_data (comics_document->archive, buf, size, &error);
5246fc
-			if (read <= 0) {
5246fc
-				if (read < 0) {
5246fc
-					g_warning ("Fatal error reading '%s' in archive: %s", name, error->message);
5246fc
-					g_error_free (error);
5246fc
+			if (size < 0) {
5246fc
+				g_warning ("Wrong size of entry '%s'.", name);
5246fc
+			} else {
5246fc
+				buf = g_malloc (size);
5246fc
+				read = ev_archive_read_data (comics_document->archive, buf, size, &error);
5246fc
+				if (read <= 0) {
5246fc
+					if (read < 0) {
5246fc
+						g_warning ("Fatal error reading '%s' in archive: %s", name, error->message);
5246fc
+						g_error_free (error);
5246fc
+					} else {
5246fc
+						g_warning ("Read an empty file from the archive");
5246fc
+					}
5246fc
 				} else {
5246fc
-					g_warning ("Read an empty file from the archive");
5246fc
+					gdk_pixbuf_loader_write (loader, (guchar *) buf, size, NULL);
5246fc
 				}
5246fc
-			} else {
5246fc
-				gdk_pixbuf_loader_write (loader, (guchar *) buf, size, NULL);
5246fc
+				g_free (buf);
5246fc
 			}
5246fc
-			g_free (buf);
5246fc
 			gdk_pixbuf_loader_close (loader, NULL);
5246fc
 			break;
5246fc
 		}
5246fc
--- evince-3.28.2/backend/pdf/ev-poppler.cc
5246fc
+++ evince-3.28.2/backend/pdf/ev-poppler.cc
5246fc
@@ -859,6 +859,7 @@ pdf_document_get_info (EvDocument *docum
5246fc
 			break;
5246fc
 		case POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT:
5246fc
 			info->layout = EV_DOCUMENT_LAYOUT_TWO_COLUMN_RIGHT;
5246fc
+			break;
5246fc
 		case POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT:
5246fc
 			info->layout = EV_DOCUMENT_LAYOUT_TWO_PAGE_LEFT;
5246fc
 			break;
5246fc
--- evince-3.28.2/cut-n-paste/libgd/gd-two-lines-renderer.c
5246fc
+++ evince-3.28.2/cut-n-paste/libgd/gd-two-lines-renderer.c
5246fc
@@ -281,7 +281,7 @@ gd_two_lines_renderer_render (GtkCellRen
5246fc
   GtkStyleContext *context;
5246fc
   gint line_one_height;
5246fc
   GtkStateFlags state;
5246fc
-  GdkRectangle area, render_area = *cell_area;
5246fc
+  GdkRectangle area, render_area;
5246fc
   gint xpad, ypad, x_offset_1, x_offset_2, y_offset;
5246fc
   PangoLayout *layout_one, *layout_two;
5246fc
   PangoRectangle layout_rect;
5246fc
--- evince-3.28.2/cut-n-paste/synctex/synctex_parser.c
5246fc
+++ evince-3.28.2/cut-n-paste/synctex/synctex_parser.c
5246fc
@@ -2878,6 +2878,7 @@ int _synctex_open(const char * output, c
5246fc
 				build_output[0] = '\0';
5246fc
 			} else {
5246fc
 				if (build_output != strcpy(build_output,output)) {
5246fc
+					free(build_output);
5246fc
 					return -4;
5246fc
 				}
5246fc
 				build_output[lpc-output]='\0';
5246fc
@@ -2886,15 +2887,18 @@ int _synctex_open(const char * output, c
5246fc
 				/*	Append a path separator if necessary. */
5246fc
 				if (!SYNCTEX_IS_PATH_SEPARATOR(build_output[strlen(build_directory)-1])) {
5246fc
 					if (build_output != strcat(build_output,"/")) {
5246fc
+						free(build_output);
5246fc
 						return -2;
5246fc
 					}
5246fc
 				}
5246fc
 				/*	Append the last path component of the output. */
5246fc
 				if (build_output != strcat(build_output,lpc)) {
5246fc
+					free(build_output);
5246fc
 					return -3;
5246fc
 				}
5246fc
 				return __synctex_open(build_output,synctex_name_ref,file_ref,add_quotes,io_mode_ref);
5246fc
 			}
5246fc
+			free(build_output);
5246fc
 		}
5246fc
 		return -1;
5246fc
 	}
5246fc
--- evince-3.28.2/cut-n-paste/synctex/synctex_parser_utils.c
5246fc
+++ evince-3.28.2/cut-n-paste/synctex/synctex_parser_utils.c
5246fc
@@ -292,6 +292,7 @@ char * _synctex_merge_strings(const char
5246fc
 		size_t len = strlen(temp);
5246fc
 		if(UINT_MAX-len
5246fc
 			_synctex_error("!  _synctex_merge_strings: Capacity exceeded.");
5246fc
+			va_end(arg);
5246fc
 			return NULL;
5246fc
 		}
5246fc
 		size+=len;
5246fc
@@ -312,6 +313,7 @@ char * _synctex_merge_strings(const char
5246fc
 						_synctex_error("!  _synctex_merge_strings: Copy problem");
5246fc
 						free(result);
5246fc
 						result = NULL;
5246fc
+						va_end(arg);
5246fc
 						return NULL;
5246fc
 					}
5246fc
 					dest += size;
5246fc
@@ -393,7 +395,7 @@ int _synctex_get_name(const char * outpu
5246fc
 					free(dir_name);
5246fc
 					dir_name = NULL;
5246fc
 					free(core_name);
5246fc
-					dir_name = NULL;
5246fc
+					core_name = NULL;
5246fc
 					return -2;
5246fc
 				}
5246fc
 				dir_name[size] = '\0';
5246fc
@@ -487,6 +489,12 @@ int _synctex_get_name(const char * outpu
5246fc
             /* set up the returned values */
5246fc
             * synctex_name_ref = synctex_name;
5246fc
             * io_mode_ref = io_mode;
5246fc
+			free(dir_name);
5246fc
+			dir_name = NULL;
5246fc
+			free(core_name);
5246fc
+			core_name = NULL;
5246fc
+			free(quoted_core_name);
5246fc
+			quoted_core_name = NULL;
5246fc
 			return 0;
5246fc
 		}
5246fc
 		return -1;/*  bad argument */
5246fc
--- evince-3.28.2/cut-n-paste/unarr/rar/filter-rar.c
5246fc
+++ evince-3.28.2/cut-n-paste/unarr/rar/filter-rar.c
5246fc
@@ -273,8 +273,10 @@ static struct RARFilter *rar_create_filt
5246fc
     filter->prog = prog;
5246fc
     filter->globaldatalen = globaldatalen > RARProgramSystemGlobalSize ? globaldatalen : RARProgramSystemGlobalSize;
5246fc
     filter->globaldata = calloc(1, filter->globaldatalen);
5246fc
-    if (!filter->globaldata)
5246fc
+    if (!filter->globaldata) {
5246fc
+        free (filter);
5246fc
         return NULL;
5246fc
+    }
5246fc
     if (globaldata)
5246fc
         memcpy(filter->globaldata, globaldata, globaldatalen);
5246fc
     if (registers)
5246fc
--- evince-3.28.2/libdocument/ev-document.c
5246fc
+++ evince-3.28.2/libdocument/ev-document.c
5246fc
@@ -496,6 +496,9 @@ ev_document_load_stream (EvDocument
5246fc
         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5246fc
 
5246fc
         klass = EV_DOCUMENT_GET_CLASS (document);
5246fc
+
5246fc
+        g_return_val_if_fail (klass != NULL, FALSE);
5246fc
+
5246fc
         if (!klass->load_stream) {
5246fc
                 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
5246fc
                                      "Backend does not support loading from stream");
5246fc
@@ -544,6 +547,9 @@ ev_document_load_gfile (EvDocument
5246fc
         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5246fc
 
5246fc
         klass = EV_DOCUMENT_GET_CLASS (document);
5246fc
+
5246fc
+        g_return_val_if_fail (klass != NULL, FALSE);
5246fc
+
5246fc
         if (!klass->load_gfile) {
5246fc
                 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
5246fc
                                      "Backend does not support loading from GFile");
5246fc
@@ -867,6 +873,9 @@ ev_document_get_backend_info (EvDocument
5246fc
 	g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
5246fc
 
5246fc
 	klass = EV_DOCUMENT_GET_CLASS (document);
5246fc
+
5246fc
+        g_return_val_if_fail (klass != NULL, FALSE);
5246fc
+
5246fc
 	if (klass->get_backend_info == NULL)
5246fc
 		return FALSE;
5246fc
 
5246fc
--- evince-3.28.2/libview/ev-pixbuf-cache.c
5246fc
+++ evince-3.28.2/libview/ev-pixbuf-cache.c
5246fc
@@ -337,6 +337,11 @@ job_finished_cb (EvJob         *job,
5246fc
 
5246fc
 	job_info = find_job_cache (pixbuf_cache, job_render->page);
5246fc
 
5246fc
+	if (job_info == NULL) {
5246fc
+		g_warning ("Job info not found.");
5246fc
+		return;
5246fc
+	}
5246fc
+
5246fc
 	if (ev_job_is_failed (job)) {
5246fc
 		job_info->job = NULL;
5246fc
 		g_object_unref (job);
5246fc
@@ -721,6 +726,11 @@ add_job_if_needed (EvPixbufCache *pixbuf
5246fc
 	gint device_scale = get_device_scale (pixbuf_cache);
5246fc
 	gint width, height;
5246fc
 
5246fc
+	if (job_info == NULL) {
5246fc
+		g_warning ("Adding job with NULL info.");
5246fc
+		return;
5246fc
+	}
5246fc
+
5246fc
 	if (job_info->job)
5246fc
 		return;
5246fc
 
5246fc
--- evince-3.28.2/libview/ev-print-operation.c
5246fc
+++ evince-3.28.2/libview/ev-print-operation.c
5246fc
@@ -181,6 +181,7 @@ ev_print_operation_set_current_page (EvP
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 	g_return_if_fail (current_page >= 0);
5246fc
 
5246fc
 	class->set_current_page (op, current_page);
5246fc
@@ -193,6 +194,7 @@ ev_print_operation_set_print_settings (E
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 	g_return_if_fail (GTK_IS_PRINT_SETTINGS (print_settings));
5246fc
 
5246fc
 	class->set_print_settings (op, print_settings);
5246fc
@@ -210,6 +212,7 @@ ev_print_operation_get_print_settings (E
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
5246fc
+	g_return_val_if_fail (class != NULL, NULL);
5246fc
 
5246fc
 	return class->get_print_settings (op);
5246fc
 }
5246fc
@@ -221,6 +224,7 @@ ev_print_operation_set_default_page_setu
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 	g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
5246fc
 
5246fc
 	class->set_default_page_setup (op, page_setup);
5246fc
@@ -238,6 +242,7 @@ ev_print_operation_get_default_page_setu
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
5246fc
+	g_return_val_if_fail (class != NULL, NULL);
5246fc
 
5246fc
 	return class->get_default_page_setup (op);
5246fc
 }
5246fc
@@ -249,6 +254,7 @@ ev_print_operation_set_job_name (EvPrint
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 	g_return_if_fail (job_name != NULL);
5246fc
 
5246fc
 	class->set_job_name (op, job_name);
5246fc
@@ -260,6 +266,7 @@ ev_print_operation_get_job_name (EvPrint
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
5246fc
+	g_return_val_if_fail (class != NULL, NULL);
5246fc
 
5246fc
 	return class->get_job_name (op);
5246fc
 }
5246fc
@@ -271,6 +278,7 @@ ev_print_operation_run (EvPrintOperation
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 
5246fc
 	class->run (op, parent);
5246fc
 }
5246fc
@@ -281,6 +289,7 @@ ev_print_operation_cancel (EvPrintOperat
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 
5246fc
 	class->cancel (op);
5246fc
 }
5246fc
@@ -292,6 +301,7 @@ ev_print_operation_get_error (EvPrintOpe
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 
5246fc
 	class->get_error (op, error);
5246fc
 }
5246fc
@@ -303,6 +313,7 @@ ev_print_operation_set_embed_page_setup
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_if_fail (EV_IS_PRINT_OPERATION (op));
5246fc
+	g_return_if_fail (class != NULL);
5246fc
 
5246fc
 	class->set_embed_page_setup (op, embed);
5246fc
 }
5246fc
@@ -313,6 +324,7 @@ ev_print_operation_get_embed_page_setup
5246fc
 	EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
5246fc
 
5246fc
 	g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), FALSE);
5246fc
+	g_return_val_if_fail (class != NULL, FALSE);
5246fc
 
5246fc
 	return class->get_embed_page_setup (op);
5246fc
 }
5246fc
--- evince-3.28.2/libview/ev-timeline.c
5246fc
+++ evince-3.28.2/libview/ev-timeline.c
5246fc
@@ -289,9 +289,15 @@ ev_timeline_new (guint duration)
5246fc
 void
5246fc
 ev_timeline_start (EvTimeline *timeline)
5246fc
 {
5246fc
+	EvTimelineClass *klass;
5246fc
+
5246fc
 	g_return_if_fail (EV_IS_TIMELINE (timeline));
5246fc
 
5246fc
-	EV_TIMELINE_GET_CLASS (timeline)->start (timeline);
5246fc
+	klass = EV_TIMELINE_GET_CLASS (timeline);
5246fc
+
5246fc
+	g_return_if_fail (klass != NULL);
5246fc
+
5246fc
+	klass->start (timeline);
5246fc
 }
5246fc
 
5246fc
 void
5246fc
--- evince-3.28.2/libview/ev-view.c
5246fc
+++ evince-3.28.2/libview/ev-view.c
5246fc
@@ -1147,7 +1147,7 @@ ensure_rectangle_is_visible (EvView *vie
5246fc
 	if (rect->x < adj_value) {
5246fc
 		value = MAX (gtk_adjustment_get_lower (adjustment), rect->x - MARGIN);
5246fc
 		gtk_adjustment_set_value (view->hadjustment, value);
5246fc
-	} else if (rect->x + rect->height > adj_value + allocation.width) {
5246fc
+	} else if (rect->x + rect->width > adj_value + allocation.width) {
5246fc
 		value = MIN (gtk_adjustment_get_upper (adjustment), rect->x + rect->width -
5246fc
 			     allocation.width + MARGIN);
5246fc
 		gtk_adjustment_set_value (view->hadjustment, value);
5246fc
@@ -1777,6 +1777,11 @@ goto_fitv_dest (EvView *view, EvLinkDest
5246fc
 
5246fc
 	page = ev_link_dest_get_page (dest);
5246fc
 
5246fc
+	if (page < 0) {
5246fc
+		g_warning ("Link does not contain a page.");
5246fc
+		return;
5246fc
+	}
5246fc
+
5246fc
 	left = ev_link_dest_get_left (dest, &change_left);
5246fc
 	doc_point.x = change_left ? left : 0;
5246fc
 	doc_point.y = 0;
5246fc
@@ -1813,6 +1818,11 @@ goto_fith_dest (EvView *view, EvLinkDest
5246fc
 
5246fc
 	page = ev_link_dest_get_page (dest);
5246fc
 
5246fc
+	if (page < 0) {
5246fc
+		g_warning ("Link does not contain a page.");
5246fc
+		return;
5246fc
+	}
5246fc
+
5246fc
 	top = ev_link_dest_get_top (dest, &change_top);
5246fc
 	doc_point.x = 0;
5246fc
 	doc_point.y = change_top ? top : 0;
5246fc
@@ -1846,6 +1856,11 @@ goto_fit_dest (EvView *view, EvLinkDest
5246fc
 
5246fc
 	page = ev_link_dest_get_page (dest);
5246fc
 
5246fc
+	if (page < 0) {
5246fc
+		g_warning ("Link does not contain a page.");
5246fc
+		return;
5246fc
+	}
5246fc
+
5246fc
 	if (view->allow_links_change_zoom) {
5246fc
 		double zoom;
5246fc
 		gdouble doc_width, doc_height;
5246fc
--- evince-3.28.2/libview/ev-view-presentation.c
5246fc
+++ evince-3.28.2/libview/ev-view-presentation.c
5246fc
@@ -448,7 +448,7 @@ ev_view_presentation_update_current_page
5246fc
 {
5246fc
 	gint jump;
5246fc
 
5246fc
-	if (page < 0 || page >= ev_document_get_n_pages (pview->document))
5246fc
+	if (page >= ev_document_get_n_pages (pview->document))
5246fc
 		return;
5246fc
 
5246fc
 	ev_view_presentation_animation_cancel (pview);
5246fc
--- evince-3.28.2/shell/ev-sidebar.c
5246fc
+++ evince-3.28.2/shell/ev-sidebar.c
5246fc
@@ -471,18 +471,19 @@ ev_sidebar_add_page (EvSidebar   *ev_sid
5246fc
 
5246fc
 
5246fc
 	/* Set the first item added as active */
5246fc
-	gtk_tree_model_get_iter_first (ev_sidebar->priv->page_model, &iter);
5246fc
-	gtk_tree_model_get (ev_sidebar->priv->page_model,
5246fc
-			    &iter,
5246fc
-			    PAGE_COLUMN_TITLE, &label_title,
5246fc
-			    PAGE_COLUMN_NOTEBOOK_INDEX, &index,
5246fc
-			    -1);
5246fc
+	if (gtk_tree_model_get_iter_first (ev_sidebar->priv->page_model, &iter)) {
5246fc
+		gtk_tree_model_get (ev_sidebar->priv->page_model,
5246fc
+				    &iter,
5246fc
+				    PAGE_COLUMN_TITLE, &label_title,
5246fc
+				    PAGE_COLUMN_NOTEBOOK_INDEX, &index,
5246fc
+				    -1);
5246fc
 
5246fc
-	gtk_menu_set_active (GTK_MENU (ev_sidebar->priv->menu), index);
5246fc
-	gtk_label_set_text (GTK_LABEL (ev_sidebar->priv->label), label_title);
5246fc
-	gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
5246fc
-				       index);
5246fc
-	g_free (label_title);
5246fc
+		gtk_menu_set_active (GTK_MENU (ev_sidebar->priv->menu), index);
5246fc
+		gtk_label_set_text (GTK_LABEL (ev_sidebar->priv->label), label_title);
5246fc
+		gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
5246fc
+					       index);
5246fc
+		g_free (label_title);
5246fc
+	}
5246fc
 }
5246fc
 
5246fc
 static gboolean
5246fc
--- evince-3.28.2/shell/ev-sidebar-thumbnails.c
5246fc
+++ evince-3.28.2/shell/ev-sidebar-thumbnails.c
5246fc
@@ -658,11 +658,11 @@ ev_sidebar_thumbnails_fill_model (EvSide
5246fc
 	int i;
5246fc
 	gint prev_width = -1;
5246fc
 	gint prev_height = -1;
5246fc
+	cairo_surface_t *loading_icon = NULL;
5246fc
 
5246fc
 	for (i = 0; i < sidebar_thumbnails->priv->n_pages; i++) {
5246fc
 		gchar     *page_label;
5246fc
 		gchar     *page_string;
5246fc
-		cairo_surface_t *loading_icon = NULL;
5246fc
 		gint       width, height;
5246fc
 
5246fc
 		page_label = ev_document_get_page_label (priv->document, i);
5246fc
--- evince-3.28.2/shell/ev-window.c
5246fc
+++ evince-3.28.2/shell/ev-window.c
5246fc
@@ -3121,10 +3121,10 @@ ev_window_load_print_settings_from_metad
5246fc
 	for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) {
5246fc
 		gchar *value = NULL;
5246fc
 
5246fc
-		ev_metadata_get_string (window->priv->metadata,
5246fc
-					document_print_settings[i], &value);
5246fc
-		gtk_print_settings_set (print_settings,
5246fc
-					document_print_settings[i], value);
5246fc
+		if (ev_metadata_get_string (window->priv->metadata,
5246fc
+					    document_print_settings[i], &value))
5246fc
+			gtk_print_settings_set (print_settings,
5246fc
+						document_print_settings[i], value);
5246fc
 	}
5246fc
 }
5246fc
 
5246fc
@@ -4705,12 +4705,16 @@ ev_window_cmd_bookmarks_add (GSimpleActi
5246fc
 	gchar     *page_label;
5246fc
 
5246fc
 	bm.page = ev_document_model_get_page (window->priv->model);
5246fc
-	page_label = ev_document_get_page_label (window->priv->document, bm.page);
5246fc
-	bm.title = g_strdup_printf (_("Page %s"), page_label);
5246fc
-	g_free (page_label);
5246fc
+	if (bm.page >= 0) {
5246fc
+		page_label = ev_document_get_page_label (window->priv->document, bm.page);
5246fc
+		bm.title = g_strdup_printf (_("Page %s"), page_label);
5246fc
+		g_free (page_label);
5246fc
 
5246fc
-	/* EvBookmarks takes ownership of bookmark */
5246fc
-	ev_bookmarks_add (window->priv->bookmarks, &bm;;
5246fc
+		/* EvBookmarks takes ownership of bookmark */
5246fc
+		ev_bookmarks_add (window->priv->bookmarks, &bm;;
5246fc
+	} else {
5246fc
+		g_warning ("Bookmarking of a page failed.");
5246fc
+	}
5246fc
 }
5246fc
 
5246fc
 static void