需要一些libsrtp内存泄漏的建议

时间:2015-06-16 09:12:04

标签: c++ c memory-leaks

我正在为我的项目使用libsrtp。我正在做srtp_init(),并在内部调用两个函数

crypto_kernel_init();
crypto_kernel_load_debug_module(&mod_srtp)

在摧毁(srtp)时,我正在呼唤

crypto_kernel_shutdown();

现在我看到下面的内存泄漏

==11435==   **25 bytes in 1 blocks are definitely lost in loss record 19 of 42**
==11435==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==11435==    by 0x44F71D: crypto_alloc (alloc.c:97)
==11435==    by 0x44FDFE: null_cipher_alloc (null_cipher.c:64)
==11435==    by 0x44B12D: cipher_type_self_test (cipher.c:264)
==11435==    by 0x44EFD2: crypto_kernel_load_cipher_type (crypto_kernel.c:310)
==11435==    by 0x44F442: crypto_kernel_init (crypto_kernel.c:151)
==11435==    by 0x449C18: srtp_init (srtp.c:1082)

==11435== **232 bytes in 1 blocks are definitely lost in loss record 34 of 42**
==11435==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==11435==    by 0x44F71D: crypto_alloc (alloc.c:97)
==11435==    by 0x451A39: aes_cbc_alloc (aes_cbc.c:71)
==11435==    by 0x44B12D: cipher_type_self_test (cipher.c:264)
==11435==    by 0x44EFD2: crypto_kernel_load_cipher_type (crypto_kernel.c:310)
==11435==    by 0x44F470: crypto_kernel_init (crypto_kernel.c:157)
==11435==    by 0x449C18: srtp_init (srtp.c:1082)
==11435== **256 bytes in 1 blocks are definitely lost in loss record 35 of 42**
==11435==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==11435==    by 0x44F71D: crypto_alloc (alloc.c:97)
==11435==    by 0x44C0BD: aes_icm_alloc_ismacryp (aes_icm.c:112)
==11435==    by 0x44C0BD: aes_icm_alloc (aes_icm.c:131)
==11435==    by 0x44B12D: cipher_type_self_test (cipher.c:264)
==11435==    by 0x44EFD2: crypto_kernel_load_cipher_type (crypto_kernel.c:310)
==11435==    by 0x44F459: crypto_kernel_init (crypto_kernel.c:154)
==11435==    by 0x449C18: srtp_init (srtp.c:1082)

请您指导我需要调用哪些函数来解决内存泄漏问题?

1 个答案:

答案 0 :(得分:1)

  

请您指导我需要调用哪些函数来解决内存泄漏问题?

否:内存泄漏要么是您使用库的错误,要么是库中的错误。所以没有“打电话给这个并做完”的修复;您必须仔细阅读代码和文档,以了解您或您的库分配内存的位置,以及您和您的库稍后无法正确发布。

不要被内存跟踪器的结果所迷惑:密码学软件通常更喜欢丢失几毫秒的内存而不会回馈给操作系统,而不是让密码敏感的内存泄露给其他进程

srtp_init可能有很好的文档说明你必须取消初始化的数据结构以及如何做到这一点,如果这是一个相关的问题(我真的不相信)。