Skip to content

Commit 732add6

Browse files
committed
crypto: avoid double free
Coverity scan reported a free after use and I think its right. Tweak to avoid double free. Signed-off-by: Michael Dawson <[email protected]> PR-URL: #40380 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent d274347 commit 732add6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/crypto/crypto_util.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,12 @@ struct EnginePointer {
562562

563563
inline void reset(ENGINE* engine_ = nullptr, bool finish_on_exit_ = false) {
564564
if (engine != nullptr) {
565-
if (finish_on_exit)
566-
ENGINE_finish(engine);
567-
ENGINE_free(engine);
565+
if (finish_on_exit) {
566+
// This also does the equivalent of ENGINE_free.
567+
CHECK_EQ(ENGINE_finish(engine), 1);
568+
} else {
569+
CHECK_EQ(ENGINE_free(engine), 1);
570+
}
568571
}
569572
engine = engine_;
570573
finish_on_exit = finish_on_exit_;

0 commit comments

Comments
 (0)