[Libreoffice] [PATCH] fix for i#115716 & fdo#33964

Caolán McNamara caolanm at redhat.com
Tue Feb 15 07:04:10 PST 2011

On Tue, 2011-02-15 at 14:50 +0000, Michael Meeks wrote:
> std::vector< char > * blob = data.newBlob();
> blob->insert(blob->begin(), str.getStr(), str.getStr() + str.getLength() + 1)
> 	As passint a char * start and end iterator to the stl insert. The end
> iterator is not used, we terminate the append before we hit it

Yes, ::insert don't dereference the final end iterator, but it does use
the one before that. So lets take a OUString str of "a", its getLength()
is 1, so the final end iterator is now str.getStr()+2. i.e. dereference
+0 for 'a' and +1 for '\0' and stop and not dereference +2, so input str
has to actually be ['a', '\0']. Which is where I was going with my
question to make sure that's the case.

The original problem to be fixed is a lack of a zero terminator in the
*output* blob, its just an issue of copying it from the original string
or adding a new one, just making sure that if we go with copying it from
the original string, that the original string has one ;-)


More information about the LibreOffice mailing list