This is an automated email from the ASF dual-hosted git repository.

chenBright pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new cb3143f6 Release the RTMP peer key after key agreement (#3501)
cb3143f6 is described below

commit cb3143f6513b6fd61c7ad3b7aa7a24167f382116
Author: Xiaofeng Wang <[email protected]>
AuthorDate: Sat Aug 29 14:44:19 2026 +0800

    Release the RTMP peer key after key agreement (#3501)
    
    Free the temporary peer public key after DH_compute_key returns so both
    successful and failed key agreement paths release it.
---
 src/brpc/policy/dh.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/brpc/policy/dh.cpp b/src/brpc/policy/dh.cpp
index cb66c9c2..cb136525 100644
--- a/src/brpc/policy/dh.cpp
+++ b/src/brpc/policy/dh.cpp
@@ -81,9 +81,9 @@ int DHWrapper::copy_shared_key(const void* ppkey, int 
ppkey_size,
     }
     // @see https://github.com/ossrs/srs/issues/165
     int key_size = DH_compute_key((unsigned char*)skey, ppk, _pdh);
+    BN_free(ppk);
     if (key_size < 0 || key_size > *skey_size) {
         LOG(ERROR) << "Fail to compute shared key";
-        BN_free(ppk);
         return -1;
     }
     *skey_size = key_size;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to