---
title: "CWE-762: Mismatched Memory Management Routines"
url: https://radicalnotion.ai/cwe/cwe-762
type: cwe
description: "The product attempts to return a memory resource to the system, but it calls a release function that is not compatible with the function that was originally used to allocate that resource."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-762: Mismatched Memory Management Routines

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Low
- **CVEs with this as primary weakness:** 16
- **Of those, in CISA KEV:** 0
- **New in 2026:** 3
- **CWE catalog version:** 4.21

## Description

The product attempts to return a memory resource to the system, but it calls a release function that is not compatible with the function that was originally used to allocate that resource.

There are multiple ways in which memory management routines can be mismatched, such as:

The memory was allocated on the stack (automatically), but it was deallocated using the memory management routine free() (CWE-590), which is intended for explicitly allocated heap memory.

The memory was allocated explicitly using one set of memory management functions, and deallocated using a different set. For example, memory might be allocated with malloc() in C++ instead of the new operator, and then deallocated with the delete operator.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Memory-Unsafe (Often), C (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Availability, Confidentiality | Modify Memory, DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands | When the memory management functions are mismatched, the consequences may be as severe as code execution, memory corruption, or program crash. Consequences and ease of exploit will vary depending on the implementation of the routines and the object being managed. |

## Potential mitigations

### Implementation

Only call matching memory management functions. Do not mix and match routines. For example, when you allocate a buffer with malloc(), dispose of the original pointer with free().

### Implementation (Libraries or Frameworks)

Choose a language or tool that provides automatic memory management, or makes manual memory management less error-prone.

For example, glibc in Linux provides protection against free of invalid pointers.

When using Xcode to target OS X or iOS, enable automatic reference counting (ARC) \[REF-391\].

To help correctly and consistently manage memory when programming in C++, consider using a smart pointer class such as std::auto\_ptr (defined by ISO/IEC ISO/IEC 14882:2003), std::shared\_ptr and std::unique\_ptr (specified by an upcoming revision of the C++ standard, informally referred to as C++ 1x), or equivalent solutions such as Boost.

### Architecture and Design (Libraries or Frameworks)

Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

For example, glibc in Linux provides protection against free of invalid pointers.

### Architecture and Design

Use a language that provides abstractions for memory allocation and deallocation.

## Detection methods

### Automated Dynamic Analysis

Use tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ \[REF-1518\] or valgrind \[REF-480\].

Effectiveness: Moderate. Crafted inputs are necessary to reach the code containing the error, such as generated by fuzzers. Also, these tools may reduce performance, and they only report the error condition - not the original mistake that led to the error.

## Demonstrative examples

### Example 1

This example allocates a BarObj object using the new operator in C++, however, the programmer then deallocates the object using free(), which may lead to unexpected behavior.

Bad code:

```c++
void foo(){
    BarObj *ptr = new BarObj()
    /* do some work with ptr here */

    ...

    free(ptr);
}
```

Good code:

```c++
void foo(){
    BarObj *ptr = new BarObj()
    /* do some work with ptr here */

    ...

    delete ptr;
}
```

Instead, the programmer should have either created the object with one of the malloc family functions, or else deleted the object with the delete operator.

### Example 2

In this example, the program does not use matching functions such as malloc/free, new/delete, and new\[\]/delete\[\] to allocate/deallocate the resource.

Bad code:

```c++
class A {
    void foo();
};
void A::foo(){
    int *ptr;
    ptr = (int*)malloc(sizeof(int));
    delete ptr;
}
```

### Example 3

In this example, the program calls the delete\[\] function on non-heap memory.

Bad code:

```c++
class A{
    void foo(bool);
};
void A::foo(bool heap) {
    int localArray[2] = {
        11,22
    };
    int *p = localArray;
    if (heap){
        p = new int[2];
    }
    delete[] p;
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2025-11015 | 3D engine rendering backend performs a delete\[\] on a buffer that was allocated using malloc() |

## Real CVEs with this weakness (sample of 12 of 16)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-48755 | - | critical | 9.8 | - | No | 2025-05-24 |
| CVE-2025-47737 | trailer mishandles allocating with a size of zero | critical | 9.8 | - | No | 2025-05-09 |
| CVE-2026-102025 | Junos OS and Junos OS Evolved: A BGP route-processing error causes rpd crash when extended next-hop tunneling and SRv6 service processing are used | high | 8.7 | - | No | 2026-10-14 |
| CVE-2025-49080 | Memory management vulnerability in Absolute Secure Access server versions 9.0 to 13.54 | high | 8.7 | - | No | 2025-06-12 |
| CVE-2026-43622 | llama.cpp b1886–b7445 Double Free via llama-android.cpp | high | 8.5 | - | No | 2026-08-06 |
| CVE-2024-32503 | - | high | 8.4 | - | No | 2024-06-07 |
| CVE-2023-41056 | Redis vulnerable to integer overflow in certain payloads | high | 8.1 | - | No | 2024-01-10 |
| CVE-2024-2955 | Mismatched Memory Management Routines in Wireshark | high | 7.8 | - | No | 2024-03-26 |
| CVE-2025-48431 | Apache Thrift: Specially crafted input can crash a c\_glib Thrift server with invalid pointer error. | high | 7.5 | - | No | 2026-04-28 |
| CVE-2023-45510 | - | high | 7.5 | - | No | 2023-10-12 |
| CVE-2025-20189 | Cisco IOS XE Software for Cisco ASR 903 Aggregation Services Routers ARP Denial of Service Vulnerability | high | 7.4 | - | No | 2025-05-07 |
| CVE-2024-4853 | Mismatched Memory Management Routines in editcap | medium | 5.5 | - | No | 2024-05-14 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-404](https://radicalnotion.ai/cwe/cwe-404) | Improper Resource Shutdown or Release |
| Parent | [CWE-763](https://radicalnotion.ai/cwe/cwe-763) | Release of Invalid Pointer or Reference |
| Child | [CWE-590](https://radicalnotion.ai/cwe/cwe-590) | Free of Memory not on the Heap |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Properly pair allocation and deallocation functions | WIN30-C | Exact |
| Software Fault Patterns | Faulty Memory Release | SFP12 | - |

## Frequently asked questions

### What is CWE-762?

The product attempts to return a memory resource to the system, but it calls a release function that is not compatible with the function that was originally used to allocate that resource.

### What CVEs are caused by CWE-762?

16 recorded CVEs are attributed to CWE-762, including CVE-2025-48755, CVE-2025-47737 and CVE-2026-102025.

### How do you prevent CWE-762?

Only call matching memory management functions. Do not mix and match routines. For example, when you allocate a buffer with malloc(), dispose of the original pointer with free().

### How is CWE-762 detected?

Automated Dynamic Analysis: Use tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ or valgrind.

### What are the consequences of CWE-762?

Exploiting CWE-762 can lead to: Modify Memory, DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands.

### Is CWE-762 actively exploited?

16 recorded CVEs are caused by CWE-762; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/762.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-762). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
