@@ -1607,9 +1607,16 @@ const char* allocStringWith0(const v8_inspector::String16& str, const void* allo
16071607// / The strings pointer and length should therefore be returned together
16081608// / @param str: The string contents to allocate
16091609// / @param allocator: A Zig std.mem.Allocator
1610- // / @param out_str: Points to the now allocated string on the heap (without sentinel \0)
1610+ // / @param out_str: Points to the now allocated string on the heap (without sentinel \0),null if view was null or allocation failed
16111611// / @param out_len: The corresponding length of the string
1612- void allocString (const v8_inspector::StringView& str, const void * allocator, const char *& out_str, size_t & out_len) {
1612+ // / @returns false if allocation errored
1613+ bool allocString (const v8_inspector::StringView& str, const void * allocator, const char *& out_str, size_t & out_len) {
1614+ if (str.characters8 () == nullptr ) {
1615+ out_str = nullptr ;
1616+ out_len = 0 ;
1617+ return true ;
1618+ }
1619+
16131620 std::string utf8_str; // Harmless if not used by 8bit string
16141621 if (str.is8Bit ()) {
16151622 out_len = str.length ();
@@ -1622,7 +1629,7 @@ void allocString(const v8_inspector::StringView& str, const void* allocator, con
16221629 if (heap_str == nullptr ) {
16231630 out_str = nullptr ;
16241631 out_len = 0 ;
1625- return ;
1632+ return false ;
16261633 }
16271634
16281635 if (str.is8Bit ()) {
@@ -1631,7 +1638,7 @@ void allocString(const v8_inspector::StringView& str, const void* allocator, con
16311638 memcpy (heap_str, utf8_str.c_str (), out_len);
16321639 }
16331640 out_str = heap_str;
1634- return ;
1641+ return true ;
16351642}
16361643
16371644
@@ -1706,15 +1713,15 @@ v8_inspector::protocol::Runtime::RemoteObject* v8_inspector__Session__wrapObject
17061713
17071714bool v8_inspector__Session__unwrapObject (
17081715 v8_inspector::V8InspectorSession *session,
1709- const void * allocator,
1710- const char * out_error,
1711- uint64_t & out_error_len,
1716+ const void * allocator,
1717+ const char *& out_error,
1718+ uint64_t & out_error_len,
17121719 const char *in_objectId,
17131720 int in_objectId_len,
1714- v8::Local<v8::Value> out_value,
1715- v8::Local<v8::Context> out_context,
1716- const char * out_objectGroup,
1717- uint64_t & out_objectGroup_len
1721+ v8::Local<v8::Value> & out_value,
1722+ v8::Local<v8::Context> & out_context,
1723+ const char *& out_objectGroup,
1724+ uint64_t & out_objectGroup_len
17181725) {
17191726 auto objectId = toStringView (in_objectId, in_objectId_len);
17201727 auto error = v8_inspector::StringBuffer::create ({});
@@ -1730,8 +1737,7 @@ bool v8_inspector__Session__unwrapObject(
17301737 allocString (error->string (), allocator, out_error, out_error_len);
17311738 return false ;
17321739 }
1733- allocString (objectGroup->string (), allocator, out_objectGroup, out_objectGroup_len);
1734- return result;
1740+ return allocString (objectGroup->string (), allocator, out_objectGroup, out_objectGroup_len);
17351741}
17361742
17371743// RemoteObject
0 commit comments