summaryrefslogtreecommitdiff
path: root/zen/serialize.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:35 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:35 +0200
commit460091fb0b2ff114cc741372f15bb43b702ea3b1 (patch)
tree0562c2eda4c66969c6e6d0910080db9f5b0def3e /zen/serialize.h
parent5.15 (diff)
downloadFreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.tar.gz
FreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.tar.bz2
FreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.zip
5.16
Diffstat (limited to 'zen/serialize.h')
-rw-r--r--zen/serialize.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/zen/serialize.h b/zen/serialize.h
index a9238359..982165f9 100644
--- a/zen/serialize.h
+++ b/zen/serialize.h
@@ -86,6 +86,7 @@ struct BinStreamIn //throw UnexpectedEndOfStreamError
const void* requestRead(size_t len) //throw UnexpectedEndOfStreamError
{
+ if (len == 0) return nullptr; //don't allow for possibility to access empty buffer
if (pos + len > buffer.size())
throw UnexpectedEndOfStreamError();
size_t oldPos = pos;
@@ -102,8 +103,9 @@ struct BinStreamOut
{
void* requestWrite(size_t len)
{
- size_t oldSize = buffer.size();
- buffer.resize(buffer.size() + len);
+ if (len == 0) return nullptr; //don't allow for possibility to access empty buffer
+ const size_t oldSize = buffer.size();
+ buffer.resize(oldSize + len);
return &*buffer.begin() + oldSize;
}
bgstack15