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
cc4611d3
Commit
cc4611d3
authored
Mar 07, 2017
by
David Renshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix isCanonical on INLINE_COMPOSITE lists with zero-sized structs
parent
8d53497a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
canonicalize-test.c++
c++/src/capnp/canonicalize-test.c++
+17
-0
layout.c++
c++/src/capnp/layout.c++
+3
-0
No files found.
c++/src/capnp/canonicalize-test.c++
View file @
cc4611d3
...
...
@@ -185,6 +185,23 @@ KJ_TEST("isCanonical rejects unused trailing words") {
KJ_ASSERT
(
!
message
.
isCanonical
());
}
KJ_TEST
(
"isCanonical accepts empty inline composite list of zero-sized structs"
)
{
AlignedData
<
3
>
segment
=
{{
// Struct pointer, pointer in next word
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
// List pointer, inline composite, zero words long
0x01
,
0x00
,
0x00
,
0x00
,
0x07
,
0x00
,
0x00
,
0x00
,
// Tag word
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
}};
kj
::
ArrayPtr
<
const
word
>
segments
[
1
]
=
{
kj
::
arrayPtr
(
segment
.
words
,
3
)};
SegmentArrayMessageReader
message
(
kj
::
arrayPtr
(
segments
,
1
));
KJ_ASSERT
(
message
.
isCanonical
());
}
KJ_TEST
(
"upgraded lists can be canonicalized"
)
{
AlignedData
<
7
>
upgradedList
=
{{
//Struct pointer, data immediately follows, 4 pointer fields, no data
...
...
c++/src/capnp/layout.c++
View file @
cc4611d3
...
...
@@ -2965,6 +2965,9 @@ bool ListReader::isCanonical(const word **readHead) {
}
auto
structSize
=
(
this
->
structDataSize
/
BITS_PER_WORD
)
+
(
this
->
structPointerCount
*
WORDS_PER_POINTER
);
if
(
structSize
==
0
*
WORDS
)
{
return
true
;
}
auto
listEnd
=
*
readHead
+
(
this
->
elementCount
/
ELEMENTS
*
structSize
)
/
WORDS
;
auto
pointerHead
=
listEnd
;
bool
listDataTrunc
=
false
;
...
...
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