Slightly improve behaviour under low memory conditions.
[dcpomatic.git] / src / lib / emailer.cc
index 7bed7ef973093939d5f293347981ec0ee396f73a..f906f5a8b320917515fef25db9ad343b0f575c09 100644 (file)
@@ -161,8 +161,14 @@ Emailer::send (string server, int port, EmailProtocol protocol, string user, str
                        "Content-Disposition: attachment; filename=" + i.name + "\r\n\r\n";
 
                auto b64 = BIO_new (BIO_f_base64());
+               if (!b64) {
+                       throw std::bad_alloc();
+               }
 
                auto bio = BIO_new (BIO_s_mem());
+               if (!bio) {
+                       throw std::bad_alloc();
+               }
                bio = BIO_push (b64, bio);
 
                ArrayData data (i.file);
@@ -231,7 +237,7 @@ Emailer::send (string server, int port, EmailProtocol protocol, string user, str
 
        auto const r = curl_easy_perform (curl);
        if (r != CURLE_OK) {
-               throw NetworkError (_("Failed to send email"), curl_easy_strerror(r));
+               throw NetworkError (_("Failed to send email"), string(curl_easy_strerror(r)));
        }
 
        curl_slist_free_all (recipients);