Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
3050b404
Commit
3050b404
authored
8 years ago
by
David Renshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug where PointerBuilder::getPointerType() can corrupt the PointerBuilder::segment field
parent
4759e273
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
any-test.c++
c++/src/capnp/any-test.c++
+21
-1
layout.c++
c++/src/capnp/layout.c++
+2
-1
No files found.
c++/src/capnp/any-test.c++
View file @
3050b404
...
...
@@ -264,7 +264,27 @@ TEST(Any, AnyStructListCapInSchema) {
#endif
}
KJ_TEST
(
"Builder::isStruct() does not corrupt segment pointer"
)
{
MallocMessageBuilder
builder
(
1
);
// small first segment
auto
root
=
builder
.
getRoot
<
AnyPointer
>
();
// Do a lot of allocations so that there is likely a segment with a decent
// amount of free space.
initTestMessage
(
root
.
initAs
<
test
::
TestAllTypes
>
());
// This will probably get allocated in a segment that still has room for the
// Data allocation below.
root
.
initAs
<
test
::
TestAllTypes
>
();
// At one point, this caused root.builder.segment to point to the segment
// where the struct is allocated, rather than segment where the root pointer
// lives, i.e. segment zero.
EXPECT_TRUE
(
root
.
isStruct
());
// If root.builder.segment points to the wrong segment and that segment has free
// space, then this triggers a DREQUIRE failure in WirePointer::setKindAndTarget().
root
.
initAs
<
Data
>
(
1
);
}
TEST
(
Any
,
Equals
)
{
MallocMessageBuilder
builderA
;
...
...
This diff is collapsed.
Click to expand it.
c++/src/capnp/layout.c++
View file @
3050b404
...
...
@@ -2428,7 +2428,8 @@ PointerType PointerBuilder::getPointerType() {
return
PointerType
::
NULL_
;
}
else
{
WirePointer
*
ptr
=
pointer
;
WireHelpers
::
followFars
(
ptr
,
ptr
->
target
(),
segment
);
SegmentBuilder
*
sgmt
=
segment
;
WireHelpers
::
followFars
(
ptr
,
ptr
->
target
(),
sgmt
);
switch
(
ptr
->
kind
())
{
case
WirePointer
:
:
FAR
:
KJ_FAIL_ASSERT
(
"far pointer not followed?"
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment