diff data/fileio/CodedAudioFileReader.cpp @ 1401:cc62d7862203

Some bits and bobs to do with handling memory pressure
author Chris Cannam
date Mon, 06 Mar 2017 17:23:46 +0000
parents 96a6ea30933e
children edee37ae5882
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp	Mon Mar 06 09:35:03 2017 +0000
+++ b/data/fileio/CodedAudioFileReader.cpp	Mon Mar 06 17:23:46 2017 +0000
@@ -478,7 +478,13 @@
 
     case CacheInMemory:
         m_dataLock.lock();
-        m_data.insert(m_data.end(), buffer, buffer + count);
+        try {
+            m_data.insert(m_data.end(), buffer, buffer + count);
+        } catch (const std::bad_alloc &e) {
+            m_data.clear();
+            m_dataLock.unlock();
+            throw e;
+        }
         m_dataLock.unlock();
         break;
     }