summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-02-09 22:21:31 +0000
committerCarl Hetherington <cth@carlh.net>2014-02-09 22:21:31 +0000
commite4b65ba64c319281d6bff15e950ebce697c9621a (patch)
tree978bf1f27d4cb65496f336c23cfb412c083a45c5 /src/lib/util.cc
parent8322da2c2ff305103ab1b180e79f470d30366699 (diff)
Fix 1 crash on low memory.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index edb202df2..190bb42b1 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -27,6 +27,7 @@
#include <iostream>
#include <fstream>
#include <climits>
+#include <stdexcept>
#ifdef DCPOMATIC_POSIX
#include <execinfo.h>
#include <cxxabi.h>
@@ -92,6 +93,7 @@ using std::istream;
using std::numeric_limits;
using std::pair;
using std::cout;
+using std::bad_alloc;
using std::streampos;
using boost::shared_ptr;
using boost::thread;
@@ -916,3 +918,14 @@ fit_ratio_within (float ratio, libdcp::Size full_frame)
return libdcp::Size (full_frame.width, rint (full_frame.width / ratio));
}
+
+void *
+wrapped_av_malloc (size_t s)
+{
+ void* p = av_malloc (s);
+ if (!p) {
+ throw bad_alloc ();
+ }
+ return p;
+}
+