diff options
author | Noel Grandin <noel@peralex.com> | 2013-10-21 09:53:57 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-10-23 13:12:55 +0200 |
commit | 8396cce9b5d9a4e3cdccc558eb1b818460f0987a (patch) | |
tree | c573d21f50405516245cbfc11630c589a098a855 /xmloff | |
parent | 763114f8b7a7705e1b28226da33bf00016ad7982 (diff) |
clean up places accessing the NULL at the of an OUString
There were only a couple of real bugs fixed, but we're a little
bit safer now.
This also fixes the assert and the comment in OUString::operator[]
about this.
Change-Id: Ibe16b5794e0ba7ecd345fa0801586d25b015974c
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/xexptran.cxx | 34 | ||||
-rw-r--r-- | xmloff/source/style/fonthdl.cxx | 2 |
2 files changed, 25 insertions, 11 deletions
diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index f97aaacc41bb..5f131251f6ee 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -151,24 +151,33 @@ void Imp_SkipDouble(const OUString& rStr, sal_Int32& rPos, const sal_Int32) sal_Unicode aChar(rStr[rPos]); if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) - aChar = rStr[++rPos]; + { + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; + } while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) || sal_Unicode('.') == aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; } if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) - aChar = rStr[++rPos]; + { + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; + } while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; } } } @@ -182,31 +191,36 @@ double Imp_GetDoubleChar(const OUString& rStr, sal_Int32& rPos, const sal_Int32 if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) || sal_Unicode('.') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } } diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index a2768e565639..b61803a04afb 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -81,7 +81,7 @@ bool XMLFontFamilyNamePropHdl::importXML( const OUString& rStrImpValue, uno::Any nFirst++; // remove quotes - sal_Unicode c = rStrImpValue[nFirst]; + sal_Unicode c = nFirst > nLast ? 0 : rStrImpValue[nFirst]; if( nFirst < nLast && (sal_Unicode('\'') == c || sal_Unicode('\"') == c) && rStrImpValue[nLast] == c ) { nFirst++; |