Skip to content

Commit adbd92e

Browse files
mhdawsontargos
authored andcommitted
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 977016a commit adbd92e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/crypto/crypto_util.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,12 @@ struct EnginePointer {
550550

551551
inline void reset(ENGINE* engine_ = nullptr, bool finish_on_exit_ = false) {
552552
if (engine != nullptr) {
553-
if (finish_on_exit)
554-
ENGINE_finish(engine);
555-
ENGINE_free(engine);
553+
if (finish_on_exit) {
554+
// This also does the equivalent of ENGINE_free.
555+
CHECK_EQ(ENGINE_finish(engine), 1);
556+
} else {
557+
CHECK_EQ(ENGINE_free(engine), 1);
558+
}
556559
}
557560
engine = engine_;
558561
finish_on_exit = finish_on_exit_;

0 commit comments

Comments
 (0)