From 5021989a29dc7e7ef1c101e591bd671c4259b7f5 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Mon, 28 Jun 2010 09:10:17 +0000 Subject: [PATCH] don't crash if no files are selected (#608047) --- xsane-0.997-no-file-selected.patch | 43 ++++++++++++++++++++++++++++++ xsane.spec | 10 ++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 xsane-0.997-no-file-selected.patch diff --git a/xsane-0.997-no-file-selected.patch b/xsane-0.997-no-file-selected.patch new file mode 100644 index 0000000..c6d1624 --- /dev/null +++ b/xsane-0.997-no-file-selected.patch @@ -0,0 +1,43 @@ +diff -up xsane-0.997/src/xsane-back-gtk.c.no-file-selected xsane-0.997/src/xsane-back-gtk.c +--- xsane-0.997/src/xsane-back-gtk.c.no-file-selected 2002-10-02 13:05:52.000000000 +0200 ++++ xsane-0.997/src/xsane-back-gtk.c 2010-06-28 10:49:29.302391248 +0200 +@@ -1501,12 +1501,19 @@ int xsane_back_gtk_get_filename(const ch + #endif + + chooser_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser)); +- strncpy(filename, chooser_filename, max_len - 1); +- g_free(chooser_filename); ++ if (chooser_filename) ++ { ++ strncpy(filename, chooser_filename, max_len - 1); ++ g_free(chooser_filename); + +- filename[max_len - 1] = '\0'; ++ filename[max_len - 1] = '\0'; + +- ok = TRUE; ++ ok = TRUE; ++ } ++ else ++ { ++ ok = FALSE; ++ } + } + + gtk_widget_destroy(filechooser); +diff -up xsane-0.997/src/xsane-front-gtk.c.no-file-selected xsane-0.997/src/xsane-front-gtk.c +--- xsane-0.997/src/xsane-front-gtk.c.no-file-selected 2002-10-02 13:04:33.000000000 +0200 ++++ xsane-0.997/src/xsane-front-gtk.c 2010-06-28 10:46:31.025142803 +0200 +@@ -1339,7 +1339,11 @@ static void xsane_browse_filename_callba + snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OUTPUT_FILENAME, xsane.device_text); + + umask((mode_t) preferences.directory_umask); /* define new file permissions */ +- xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, &preferences.filetype, &preferences.cms_function, XSANE_FILE_CHOOSER_ACTION_SELECT_SAVE, show_extra_widgets, XSANE_FILE_FILTER_ALL | XSANE_FILE_FILTER_IMAGES, XSANE_FILE_FILTER_IMAGES); ++ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, &preferences.filetype, &preferences.cms_function, XSANE_FILE_CHOOSER_ACTION_SELECT_SAVE, show_extra_widgets, XSANE_FILE_FILTER_ALL | XSANE_FILE_FILTER_IMAGES, XSANE_FILE_FILTER_IMAGES)) ++ { ++ xsane_set_sensitivity(TRUE); ++ return; ++ } + umask(XSANE_DEFAULT_UMASK); /* define new file permissions */ + + if (preferences.filename) diff --git a/xsane.spec b/xsane.spec index cae2e6f..a8f8d96 100644 --- a/xsane.spec +++ b/xsane.spec @@ -6,7 +6,7 @@ Name: xsane Summary: X Window System front-end for the SANE scanner interface Version: 0.997 -Release: 5%{?dist} +Release: 6%{?dist} Source0: http://www.xsane.org/download/%{name}-%{version}.tar.gz Source1: xsane.desktop # distro-specific: use "xdg-open" instead of "netscape" to launch help browser @@ -19,6 +19,9 @@ Patch2: xsane-0.996-no-eula.patch # enable off-root building # submitted to upstream (Oliver Rauch) via email, 2010-06-23 Patch3: xsane-0.997-off-root-build.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=608047 +# submitted to upstream (Oliver Rauch) via email, 2010-06-28 +Patch4: xsane-0.997-no-file-selected.patch # autoconf-generated files Patch10: xsane-0.997-5-autoconf.patch.bz2 License: GPLv2+ @@ -73,6 +76,8 @@ done %patch1 -p1 -b .close-fds %patch2 -p1 -b .no-eula %patch3 -p1 -b .off-root-build +%patch4 -p1 -b .no-file-selected + %patch10 -p1 -b .autoconf # in-root config.h breaks off-root building @@ -144,6 +149,9 @@ fi %{_datadir}/sane/xsane %changelog +* Mon Jun 28 2010 Nils Philippsen 0.997-6 +- don't crash if no files are selected (#608047) + * Wed Jun 23 2010 Nils Philippsen 0.997-5 - don't use gimp-plugin-mgr anymore - use off-root builds