zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #08470
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-914955 into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
Matthias Brantner (matthias-brantner)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-914955/+merge/103272
Fixing case where accessing an empty vector with position 0 in base64binary (causes assertion on Windows to be hit).
--
https://code.launchpad.net/~zorba-coders/zorba/bug-914955/+merge/103272
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2012-04-23 10:46:38 +0000
+++ src/store/naive/atomic_items.cpp 2012-04-24 13:01:39 +0000
@@ -3318,7 +3318,7 @@
Base64BinaryItem::getBase64BinaryValue(size_t& size) const
{
size = theValue.size();
- return &theValue[0];
+ return size > 0 ? &theValue[0] : "";
}
@@ -3345,6 +3345,10 @@
void Base64BinaryItem::appendStringValue(zstring& buf) const
{
+ if (theValue.empty())
+ {
+ return;
+ }
if (theIsEncoded)
{
buf.insert(buf.size(), &theValue[0], theValue.size());
@@ -3497,14 +3501,22 @@
if (isSeekable())
{
lStream.seekg(0, std::ios::end);
- size_t len = lStream.tellg();
+ std::streampos len = lStream.tellg();
lStream.seekg(0, std::ios::beg);
+ if (len < 0)
+ {
+ throw ZORBA_EXCEPTION( zerr::ZOSE0003_STREAM_READ_FAILURE );
+ }
+ if (len == 0)
+ {
+ return;
+ }
s->theValue.reserve(len);
char buf[1024];
while (lStream.good())
{
lStream.read(buf, 1024);
- s->theValue.insert(s->theValue.end(), buf, buf+lStream.gcount());
+ s->theValue.insert(s->theValue.end(), buf, buf + lStream.gcount());
}
}
else
@@ -3513,8 +3525,11 @@
while (lStream.good())
{
lStream.read(buf, 4048);
- s->theValue.reserve(s->theValue.size() + lStream.gcount());
- s->theValue.insert(s->theValue.end(), buf, buf+lStream.gcount());
+ if (lStream.gcount() > 0)
+ {
+ s->theValue.reserve(s->theValue.size() + lStream.gcount());
+ s->theValue.insert(s->theValue.end(), buf, buf + lStream.gcount());
+ }
}
}
}
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: noreply, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-25
-
Re: [Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Ghislain Fourny, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Ghislain Fourny, 2012-04-25
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-24
-
Re: [Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-24
-
Re: [Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Markos Zaharioudakis, 2012-04-24
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Zorba Build Bot, 2012-04-24
-
Re: [Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Matthias Brantner, 2012-04-24
-
[Merge] lp:~zorba-coders/zorba/bug-914955 into lp:zorba
From: Ghislain Fourny, 2012-04-24