LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File uniprint-catch-bad_alloc-exceptions.patch of Package yudit (Project home:linux4humans:sle11_software:M17N)

Index: yudit-2.9.2/uniprint/Main.cpp
===================================================================
--- yudit-2.9.2.orig/uniprint/Main.cpp
+++ yudit-2.9.2/uniprint/Main.cpp
@@ -37,6 +37,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <new>
+
 #define BUFFER_SIZE 512
 
 static const char *version="uniprint verison %s GNU(c) Gaspar Sinai\n";
@@ -318,11 +320,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)
   {