summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-06 10:24:10 +0200
committerGitHub <noreply@github.com>2022-05-06 10:24:10 +0200
commit514df84d9fbd0e6d4661b4fa4a172db472f5c240 (patch)
tree47e14bafe7abb809305c1325f713ad3e6d0dca24 /vespalib
parentb4838b56acf46816461a5affca82aac55f532070 (diff)
parent9672b125531f4d3eda3d8483cf1d63d71ebc9875 (diff)
Merge pull request #22468 from vespa-engine/vekterli/avoid-nullptr-ref-from-empty-file-read
Early return from asciistream file read if file is empty
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index eb127c7051a..6b673363d2d 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -628,6 +628,9 @@ asciistream::createFromFile(stringref fileName)
if (sz < 0) {
throw IoException("Failed getting size of file " + fileName + " : Error=" + file.getLastErrorString(), IoException::UNSPECIFIED, VESPA_STRLOC);
}
+ if (sz == 0) {
+ return is;
+ }
alloc::Alloc buf = alloc::Alloc::alloc(sz);
ssize_t actual = file.Read(buf.get(), sz);
if (actual != sz) {