Skip to content

Commit

Permalink
Check for NULL before calling ZSTD_free?Ctx
Browse files Browse the repository at this point in the history
Summary:
The current ZSTD_free?Ctx functions check for null inputs, but versions prior to 0.7.0 do not.  Ubuntu 16.04 ships with verion 0.5.1-1, so this can cause a crash.  Add the check for null ourselves.

facebook#675

Squash with: D4511885

Reviewed By: lth

Differential Revision: D6477750

fbshipit-source-id: 6c1de42
  • Loading branch information
jkedgar authored and facebook-github-bot committed Dec 4, 2017
1 parent bffb8d7 commit bfc45c8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sql/net_serv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,16 @@ void net_end(NET *net)
reset_packet_write_state(net);
#endif
#ifdef HAVE_ZSTD_COMPRESS
ZSTD_freeCCtx(net->cctx);
ZSTD_freeDCtx(net->dctx);
net->cctx = NULL;
net->dctx = NULL;
// ZSTD_freeCCtx and ZSTD_freeDCtx were updated to check for NULL input
// in 0.7.0, but Ubuntu ships with 0.5.1-1, so check here.
if (net->cctx != NULL) {
ZSTD_freeCCtx(net->cctx);
net->cctx = NULL;
}
if (net->dctx != NULL) {
ZSTD_freeDCtx(net->dctx);
net->dctx = NULL;
}
#endif
my_free(net->buff);
net->buff=0;
Expand Down

0 comments on commit bfc45c8

Please sign in to comment.