summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webframe_impl.cc
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 15:26:28 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 15:26:28 +0000
commitd499ed582b58cf676becdc97ca7280861a9483b0 (patch)
tree46fb4dc60177ac4caec27f3ad66da4f4712c2c62 /webkit/glue/webframe_impl.cc
parent59b260797e0201b7b5e4a06c9babb5aabcbed160 (diff)
downloadchromium_src-d499ed582b58cf676becdc97ca7280861a9483b0.zip
chromium_src-d499ed582b58cf676becdc97ca7280861a9483b0.tar.gz
chromium_src-d499ed582b58cf676becdc97ca7280861a9483b0.tar.bz2
Add a unit test for getting the text of a webframe. This fixes a serious crash my previous test introduces.
BUG=1332060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframe_impl.cc')
-rw-r--r--webkit/glue/webframe_impl.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 1617c57..03242b6 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -206,20 +206,25 @@ static void FrameContentAsPlainText(int max_chars, Frame* frame,
// string conversion.
for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
const wchar_t* chars = reinterpret_cast<const wchar_t*>(it.characters());
- if (!chars && it.length() != 0) {
- // It appears from crash reports that an iterator can get into a state
- // where the character count is nonempty but the character pointer is
- // NULL. advance()ing it will then just add that many to the NULL
- // pointer which won't be caught in a NULL check but will crash.
- //
- // A NULL pointer and 0 length is common for some nodes.
- //
- // IF YOU CATCH THIS IN A DEBUGGER please let brettw know. We don't
- // currently understand the conditions for this to occur. Ideally, the
- // iterators would never get into the condition so we should fix them
- // if we can.
- NOTREACHED();
- break;
+ if (!chars) {
+ if (it.length() != 0) {
+ // It appears from crash reports that an iterator can get into a state
+ // where the character count is nonempty but the character pointer is
+ // NULL. advance()ing it will then just add that many to the NULL
+ // pointer which won't be caught in a NULL check but will crash.
+ //
+ // A NULL pointer and 0 length is common for some nodes.
+ //
+ // IF YOU CATCH THIS IN A DEBUGGER please let brettw know. We don't
+ // currently understand the conditions for this to occur. Ideally, the
+ // iterators would never get into the condition so we should fix them
+ // if we can.
+ NOTREACHED();
+ break;
+ }
+
+ // Just got a NULL node, we can forge ahead!
+ continue;
}
int to_append = std::min(it.length(),
max_chars - static_cast<int>(output->size()));