Re: [Gimp-developer] Fix possible uninitialized variable access



A small change to the earlier patch. Though poppler does not return negative for *get*n_pages, it helps for coverity when we check for < 0.

On Wed, Dec 7, 2011 at 8:12 AM, Karthikeyan S <karthikdevel gmail com> wrote:
-Karthik

From dc709a2450917ed5f71df604d1415f80fb6bf6c2 Mon Sep 17 00:00:00 2001
From: Karthikeyan S <karthikdevel gmail com>
Date: Wed, 7 Dec 2011 17:57:28 +0530
Subject: [PATCH] Fix possible uninitialised variable access

Print a message to the user if poppler returns n_pages = 0.
Return to file open dialog.
This way we prevent uninitialised variable access down the line.
---
 plug-ins/common/file-pdf-load.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/plug-ins/common/file-pdf-load.c b/plug-ins/common/file-pdf-load.c
index 00c78f5..4138e74 100644
--- a/plug-ins/common/file-pdf-load.c
+++ b/plug-ins/common/file-pdf-load.c
@@ -1101,6 +1101,13 @@ load_dialog (PopplerDocument  *doc,
   gtk_widget_show (selector);
 
   n_pages = poppler_document_get_n_pages (doc);
+
+  if (n_pages <= 0)
+  {
+    gimp_message (_("Error getting number of pages from the given pdf file\n"));
+    return FALSE;
+  }
+
   gimp_page_selector_set_n_pages (GIMP_PAGE_SELECTOR (selector), n_pages);
   gimp_page_selector_set_target (GIMP_PAGE_SELECTOR (selector),
                                  loadvals.target);
-- 
1.7.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]