Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <mail@ckamm.de>2019-06-05 15:50:46 +0300
committerChristian Kamm <mail@ckamm.de>2019-07-23 10:00:20 +0300
commitd5ab19ebf3ddf486ce58ff3ab712c5b4cdade45d (patch)
treeaf7420c7e40ed03c6ad553b73db9e3a776a55040
parent0e440f3b7eda4c66eda6c4a6c87e54c7f5ccb7f6 (diff)
Upload: Catch out-of-memory error #68802.5
This will avoid a rare-but-regular crash in low-memory situations. Note that this is a workaround: In 2.6 this code should be adjusted to not read a full file chunk into memory immediately and instead load more data on demand.
-rw-r--r--src/libsync/propagateupload.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index a8b260515..e21eb7028 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -341,7 +341,12 @@ bool UploadDevice::prepareAndOpen(const QString &fileName, qint64 start, qint64
}
size = qBound(0ll, size, FileSystem::getSize(fileName) - start);
- _data.resize(size);
+ try {
+ _data.resize(size);
+ } catch (const std::bad_alloc &) {
+ setErrorString(tr("Not enough memory to allocate file buffer of size %1").arg(size));
+ return false;
+ }
auto read = file.read(_data.data(), size);
if (read != size) {
setErrorString(file.errorString());