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
c9f65022
Commit
c9f65022
authored
Apr 21, 2017
by
David Renshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust AnyList::equals(): a list of pointers cannot equal a struct list
parent
9d764566
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
any-test.c++
c++/src/capnp/any-test.c++
+25
-0
any.c++
c++/src/capnp/any.c++
+5
-4
No files found.
c++/src/capnp/any-test.c++
View file @
c9f65022
...
...
@@ -377,6 +377,31 @@ KJ_TEST("Bit list with nonzero pad bits") {
KJ_ASSERT
(
message1
.
getRoot
<
AnyList
>
()
==
message2
.
getRoot
<
AnyList
>
());
}
KJ_TEST
(
"Pointer list unequal to struct list"
)
{
AlignedData
<
2
>
segment1
=
{{
// list with zero pointer-sized elements
0x01
,
0x00
,
0x00
,
0x00
,
0x06
,
0x00
,
0x00
,
0x00
,
}};
kj
::
ArrayPtr
<
const
word
>
segments1
[
1
]
=
{
kj
::
arrayPtr
(
segment1
.
words
,
2
)
};
SegmentArrayMessageReader
message1
(
kj
::
arrayPtr
(
segments1
,
1
));
AlignedData
<
2
>
segment2
=
{{
// struct list of length zero
0x01
,
0x00
,
0x00
,
0x00
,
0x07
,
0x00
,
0x00
,
0x00
,
// struct list tag, zero elements
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
}};
kj
::
ArrayPtr
<
const
word
>
segments2
[
1
]
=
{
kj
::
arrayPtr
(
segment2
.
words
,
2
)
};
SegmentArrayMessageReader
message2
(
kj
::
arrayPtr
(
segments2
,
1
));
EXPECT_EQ
(
Equality
::
NOT_EQUAL
,
message1
.
getRoot
<
AnyList
>
().
equals
(
message2
.
getRoot
<
AnyList
>
()));
}
}
// namespace
}
// namespace _ (private)
}
// namespace capnp
c++/src/capnp/any.c++
View file @
c9f65022
...
...
@@ -141,6 +141,11 @@ Equality AnyList::Reader::equals(AnyList::Reader right) {
if
(
size
()
!=
right
.
size
())
{
return
Equality
::
NOT_EQUAL
;
}
if
(
getElementSize
()
!=
right
.
getElementSize
())
{
return
Equality
::
NOT_EQUAL
;
}
auto
eqResult
=
Equality
::
EQUAL
;
switch
(
getElementSize
())
{
case
ElementSize
:
:
VOID
:
...
...
@@ -149,10 +154,6 @@ Equality AnyList::Reader::equals(AnyList::Reader right) {
case
ElementSize
:
:
TWO_BYTES
:
case
ElementSize
:
:
FOUR_BYTES
:
case
ElementSize
:
:
EIGHT_BYTES
:
{
if
(
getElementSize
()
!=
right
.
getElementSize
())
{
return
Equality
::
NOT_EQUAL
;
}
size_t
cmpSize
=
getRawBytes
().
size
();
if
(
getElementSize
()
==
ElementSize
::
BIT
&&
size
()
%
8
!=
0
)
{
...
...
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