# CVE-2021-40145: gdImageGd2Ptr in gdgd2.c in the GD Graphics Library (aka LibGD) through 2.3.2 has a double free.

- Severity: High 7.5 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 2.13%, higher than 83% of CVEs (2026-11-30)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2021-08-26T00:34:17.000Z
- Modified: 2026-06-17T04:06:35.353Z
- Weaknesses: CWE-415
- Assigned by: mitre

## Description

gdImageGd2Ptr in gd_gd2.c in the GD Graphics Library (aka LibGD) through 2.3.2 has a double free. NOTE: the vendor's position is "The GD2 image format is a proprietary image format of libgd. It has to be regarded as being obsolete, and should only be used for development and testing purposes.

(As written by CVE List.)

## Affected

- Unspecified product: n/a
- libgd libgd: up to 2.3.2

## Every score

- NVD: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:2.0 5.0 Medium `AV:N/AC:L/Au:N/C:N/I:N/A:P`

## References

- <https://github.com/libgd/libgd/issues/700> (exploit, issue-tracking, third-party-advisory)
- <https://github.com/libgd/libgd/commit/c5fd25ce0e48fd5618a972ca9f5e28d6d62006af> (patch, third-party-advisory)
- <https://github.com/libgd/libgd/pull/713> (issue-tracking, third-party-advisory)

## Sources

- CVE List: [CVE-2021-40145](https://www.cve.org/CVERecord?id=CVE-2021-40145), CVE Terms of Use, modified 2024-08-04
- NVD: [CVE-2021-40145](https://nvd.nist.gov/vuln/detail/CVE-2021-40145), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-40145 · Whole record: https://cve.day/CVE-2021-40145.json · Rebuilt by cve.day 2026-11-25T22:58:03.509Z
