Fix segmentation fault when libpaper is unconfigured
When barcode is compiled with support for libpaper, but libpaper is not
configured and papersize environment variables are not set, systempapername()
returns NULL. This causes get_page_geometry() to crash subsequently.
Source code for libpaper suggests that users are expected to call
defaultpapername() and use its return value instead if that happens.
Additionally, add a check that will only call get_page_geometry() with non-NULL
Signed-off-by: Clemens Lang <cal@macports.org>
Upstream-Status: Submitted [http://lists.gnu.org/archive/html/bug-barcode/2015-12/msg00000.html]
--- main.c.orig 2015-12-10 23:47:45.000000000 +0100
+++ main.c 2015-12-10 23:51:03.000000000 +0100
/* If no paper size has been specified, use the default, if any */
+ const char *papername = systempapername(); /* or the system default */
+ papername = defaultpapername();
page_wid = 595; page_hei = 842;
page_name = "A4"; /* I live in Europe :) */
- get_page_geometry(systempapername()); /* or the system default */
+ get_page_geometry(papername);