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
40d46a81
Commit
40d46a81
authored
Jun 12, 2018
by
Ingvar Stepanyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix double-free after move of context
parent
e57066ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
gzip-test.c++
c++/src/kj/compat/gzip-test.c++
+1
-1
gzip.c++
c++/src/kj/compat/gzip.c++
+8
-2
gzip.h
c++/src/kj/compat/gzip.h
+8
-13
No files found.
c++/src/kj/compat/gzip-test.c++
View file @
40d46a81
...
...
@@ -214,7 +214,7 @@ KJ_TEST("async gzip decompression") {
// Decompress using an output stream.
{
MockAsyncOutputStream
rawOutput
;
auto
gzip
=
GzipAsyncOutputStream
::
Decompress
(
rawOutput
);
GzipAsyncOutputStream
gzip
(
rawOutput
,
GzipAsyncOutputStream
::
DECOMPRESS
);
auto
mid
=
sizeof
(
FOOBAR_GZIP
)
/
2
;
gzip
.
write
(
FOOBAR_GZIP
,
mid
).
wait
(
io
.
waitScope
);
...
...
c++/src/kj/compat/gzip.c++
View file @
40d46a81
...
...
@@ -142,9 +142,12 @@ size_t GzipInputStream::readImpl(
// =======================================================================================
GzipOutputStream
::
GzipOutputStream
(
OutputStream
&
inner
,
kj
::
Maybe
<
int
>
compressionLevel
)
GzipOutputStream
::
GzipOutputStream
(
OutputStream
&
inner
,
int
compressionLevel
)
:
inner
(
inner
),
ctx
(
compressionLevel
)
{}
GzipOutputStream
::
GzipOutputStream
(
OutputStream
&
inner
,
decltype
(
DECOMPRESS
))
:
inner
(
inner
),
ctx
(
nullptr
)
{}
GzipOutputStream
::~
GzipOutputStream
()
noexcept
(
false
)
{
pump
(
Z_FINISH
);
}
...
...
@@ -228,9 +231,12 @@ Promise<size_t> GzipAsyncInputStream::readImpl(
// =======================================================================================
GzipAsyncOutputStream
::
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
kj
::
Maybe
<
int
>
compressionLevel
)
GzipAsyncOutputStream
::
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
int
compressionLevel
)
:
inner
(
inner
),
ctx
(
compressionLevel
)
{}
GzipAsyncOutputStream
::
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
decltype
(
DECOMPRESS
))
:
inner
(
inner
),
ctx
(
nullptr
)
{}
Promise
<
void
>
GzipAsyncOutputStream
::
write
(
const
void
*
in
,
size_t
size
)
{
ctx
.
setInput
(
in
,
size
);
return
pump
(
Z_NO_FLUSH
);
...
...
c++/src/kj/compat/gzip.h
View file @
40d46a81
...
...
@@ -34,7 +34,6 @@ public:
GzipOutputContext
(
kj
::
Maybe
<
int
>
compressionLevel
);
~
GzipOutputContext
()
noexcept
(
false
);
KJ_DISALLOW_COPY
(
GzipOutputContext
);
GzipOutputContext
(
GzipOutputContext
&&
)
=
default
;
void
setInput
(
const
void
*
in
,
size_t
size
);
kj
::
Tuple
<
bool
,
kj
::
ArrayPtr
<
const
byte
>>
pumpOnce
(
int
flush
);
...
...
@@ -69,14 +68,12 @@ private:
class
GzipOutputStream
final
:
public
OutputStream
{
public
:
GzipOutputStream
(
OutputStream
&
inner
,
kj
::
Maybe
<
int
>
compressionLevel
=
Z_DEFAULT_COMPRESSION
);
enum
{
DECOMPRESS
};
GzipOutputStream
(
OutputStream
&
inner
,
int
compressionLevel
=
Z_DEFAULT_COMPRESSION
);
GzipOutputStream
(
OutputStream
&
inner
,
decltype
(
DECOMPRESS
));
~
GzipOutputStream
()
noexcept
(
false
);
KJ_DISALLOW_COPY
(
GzipOutputStream
);
GzipOutputStream
(
GzipOutputStream
&&
)
=
default
;
static
inline
GzipOutputStream
Decompress
(
OutputStream
&
inner
)
{
return
GzipOutputStream
(
inner
,
nullptr
);
}
void
write
(
const
void
*
buffer
,
size_t
size
)
override
;
using
OutputStream
::
write
;
...
...
@@ -112,13 +109,11 @@ private:
class
GzipAsyncOutputStream
final
:
public
AsyncOutputStream
{
public
:
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
kj
::
Maybe
<
int
>
compressionLevel
=
Z_DEFAULT_COMPRESSION
);
KJ_DISALLOW_COPY
(
GzipAsyncOutputStream
);
GzipAsyncOutputStream
(
GzipAsyncOutputStream
&&
)
=
default
;
enum
{
DECOMPRESS
};
static
inline
GzipAsyncOutputStream
Decompress
(
AsyncOutputStream
&
inner
)
{
return
GzipAsyncOutputStream
(
inner
,
nullptr
);
}
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
int
compressionLevel
=
Z_DEFAULT_COMPRESSION
);
GzipAsyncOutputStream
(
AsyncOutputStream
&
inner
,
decltype
(
DECOMPRESS
)
);
KJ_DISALLOW_COPY
(
GzipAsyncOutputStream
);
Promise
<
void
>
write
(
const
void
*
buffer
,
size_t
size
)
override
;
Promise
<
void
>
write
(
ArrayPtr
<
const
ArrayPtr
<
const
byte
>>
pieces
)
override
;
...
...
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