File uniprint-catch-bad_alloc-exceptions.patch of Package yudit
Index: yudit-2.9.0/uniprint/Main.cpp
===================================================================
--- yudit-2.9.0.orig/uniprint/Main.cpp
+++ yudit-2.9.0/uniprint/Main.cpp
@@ -37,6 +37,8 @@
#include <string.h>
#include <stdlib.h>
+#include <new>
+
#define BUFFER_SIZE 512
static char *version="uniprint verison %s GNU(c) Gaspar Sinai\n";
@@ -314,11 +316,20 @@ main (int argc, char *argv[])
uniPrint.setLineEndMark(shownl);
uniPrint.setWordWrap(wrap);
- if (!uniPrint.print (ifileString, utf8.encode (res)))
+ try
{
- fprintf (stderr, "uniprint: can not print.\n");
+ if (!uniPrint.print (ifileString, utf8.encode (res)))
+ {
+ fprintf (stderr, "uniprint: can not print.\n");
+ return 1;
+ }
+ }
+ catch (std::bad_alloc)
+ {
+ fprintf (stderr, "uniprint: can not print (out of memory).\n");
return 1;
}
+
int pagecount = uniPrint.getPageCount();
if (pagecount > 1)
{