[gnutls-devel] libtasn1 | memory leaks in asn1_array2tree (#26)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Mon Mar 6 12:18:13 CET 2023




wang cheng commented:


By carefully reviewing the code he submitted, I found that the memory leak described in this issue does not exist. I guess the memory leak described by this issue is as follows: 
```
A---B---C
    |
    D
```
Assuming that A has been added to the tree (the structure is shown above), now a new node E needs to be added to the right of A. At this time, the following function will be called to delete the right node of A:
```
if (p_last && p_last->down)
   _asn1_delete_structure (e_list, &p_last->down, 0);

```
The memory leak of the node C will be caused. So this [commit](https://gitlab.com/gnutls/libtasn1/-/merge_requests/62) uses a while loop to continue deleting node C. 
But the problem described above will not appear in the `asn1_array2tree` function, because the new node creation function `_asn1_add_static_node` uses `calloc` to allocate memory. Perhaps this judgment `if (p_last && p_last->down)` is redundant.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/libtasn1/-/issues/26#note_1302077208
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20230306/e8510868/attachment.html>


More information about the Gnutls-devel mailing list