Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: test/cctest/test-strings.cc

Issue 603393004: String::NewExternal should not crash the renderer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index ef13c4dadf682f6e178dce71c9e70009d703a7e9..da21d3309cf0498d7154ac37333375b6814499bc 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1373,15 +1373,21 @@ TEST(Latin1IgnoreCase) {
class DummyResource: public v8::String::ExternalStringResource {
public:
- virtual const uint16_t* data() const { return NULL; }
+ virtual const uint16_t* data() const { return string_; }
virtual size_t length() const { return 1 << 30; }
+
+ private:
+ uint16_t string_[10];
yurys 2014/09/26 09:30:34 Length 1 should be enough
};
class DummyOneByteResource: public v8::String::ExternalOneByteStringResource {
public:
- virtual const char* data() const { return NULL; }
+ virtual const char* data() const { return string_; }
virtual size_t length() const { return 1 << 30; }
+
+ private:
+ char string_[10];
yurys 2014/09/26 09:30:34 ditto
};
@@ -1402,6 +1408,24 @@ TEST(InvalidExternalString) {
CHECK(isolate->has_pending_exception());
isolate->clear_pending_exception();
}
+
+ {
+ HandleScope scope(isolate);
+ DummyOneByteResource r;
+ v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r);
+ CHECK(str.IsEmpty());
+ CHECK(isolate->has_pending_exception());
+ isolate->clear_pending_exception();
+ }
+
+ {
+ HandleScope scope(isolate);
+ DummyResource r;
+ v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r);
+ CHECK(str.IsEmpty());
+ CHECK(isolate->has_pending_exception());
+ isolate->clear_pending_exception();
+ }
}
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698