---
title: "CWE-763: Release of Invalid Pointer or Reference"
url: https://radicalnotion.ai/cwe/cwe-763
type: cwe
description: "The product attempts to return a memory resource to the system, but it calls the wrong release function or calls the appropriate release function incorrectly."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-763: Release of Invalid Pointer or Reference

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 184
- **Of those, in CISA KEV:** 0
- **New in 2026:** 85
- **CWE catalog version:** 4.21

## Description

The product attempts to return a memory resource to the system, but it calls the wrong release function or calls the appropriate release function incorrectly.

This weakness can take several forms, such as:

The memory was allocated, explicitly or implicitly, via one memory management method and deallocated using a different, non-compatible function (CWE-762).

The function calls or memory management routines chosen are appropriate, however they are used incorrectly, such as in CWE-761.

## Modes of introduction

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

## Applicable platforms

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Availability, Confidentiality | Modify Memory, DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands | This weakness may result in the corruption of memory, and perhaps instructions, possibly leading to a crash. If the corrupted memory can be effectively controlled, it may be possible to execute arbitrary code. |

## 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

When programming in C++, consider using smart pointers provided by the boost library to help correctly and consistently manage memory.

### 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

### Fuzzing

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

Effectiveness: High

### 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 code attempts to tokenize a string and place it into an array using the strsep function, which inserts a \\0 byte in place of whitespace or a tab character. After finishing the loop, each string in the AP array points to a location within the input string.

Bad code:

```c
char **ap, *argv[10], *inputstring;
for (ap = argv; (*ap = strsep(&inputstring, " \t")) != NULL;)
    if (**ap != '\0')
        if (++ap >= &argv[10])
            break;

/.../
free(ap[4]);
```

Since strsep is not allocating any new memory, freeing an element in the middle of the array is equivalent to free a pointer in the middle of inputstring.

### Example 2

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 3

In this example, the programmer dynamically allocates a buffer to hold a string and then searches for a specific character. After completing the search, the programmer attempts to release the allocated memory and return SUCCESS or FAILURE to the caller. Note: for simplification, this example uses a hard-coded "Search Me!" string and a constant string length of 20.

Bad code:

```c
#define SUCCESS (1)
#define FAILURE (0)

int contains_char(char c){
    char *str;
    str = (char*)malloc(20*sizeof(char));
    strcpy(str, "Search Me!");
    while( *str != NULL){
        if( *str == c ){

            /* matched char, free string and return success */
            free(str);
            return SUCCESS;
        }
        /* didn't match yet, increment pointer and try next char */

        str = str + 1;
    }
    /* we did not match the char in the string, free mem and return failure */

    free(str);
    return FAILURE;
}
```

Good code:

```c
#define SUCCESS (1)
#define FAILURE (0)

int contains_char(char c){
    char *str;
    int i = 0;
    str = (char*)malloc(20*sizeof(char));
    strcpy(str, "Search Me!");
    while( i < strlen(str) ){
        if( str[i] == c ){

            /* matched char, free string and return success */
            free(str);
            return SUCCESS;
        }
        /* didn't match yet, increment pointer and try next char */

        i = i + 1;
    }
    /* we did not match the char in the string, free mem and return failure */

    free(str);
    return FAILURE;
}
```

### Example 4

Consider the following code in the context of a parsing application to extract commands out of user data. The intent is to parse each command and add it to a queue of commands to be executed, discarding each malformed entry.

Bad code:

```c
//hardcode input length for simplicity
char* input = (char*) malloc(40*sizeof(char));
char *tok;
char* sep = " \t";

get_user_input( input );

/* The following loop will parse and process each token in the input string */

tok = strtok( input, sep);
while( NULL != tok ){
    if( isMalformed( tok ) ){

        /* ignore and discard bad data */
        free( tok );
    }
    else{
        add_to_command_queue( tok );
    }
    tok = strtok( NULL, sep));
}
```

Good code:

```c
//hardcode input length for simplicity
char* input = (char*) malloc(40*sizeof(char));
char *tok, *command;
char* sep = " \t";

get_user_input( input );

/* The following loop will parse and process each token in the input string */

tok = strtok( input, sep);
while( NULL != tok ){
    if( !isMalformed( command ) ){

        /* copy and enqueue good data */
        command = (char*) malloc( (strlen(tok) + 1) * sizeof(char) );
        strcpy( command, tok );
        add_to_command_queue( command );
    }
    tok = strtok( NULL, sep));
}

free( input )
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2025-11015 | 3D engine rendering backend performs a delete\[\] on a buffer that was allocated using malloc() |
| CVE-2019-11930 | function "internally calls 'calloc' and returns a pointer at an index... inside the allocated buffer. This led to freeing invalid memory." |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-88234 | Windows iSCSI Remote Code Execution Vulnerability | critical | 9.8 | - | No | 2026-11-10 |
| CVE-2026-74478 | um: vector: fix use-after-free in vector\_mmsg\_rx() | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2026-53000 | netfilter: nat: use kfree\_rcu to release ops | critical | 9.8 | - | No | 2026-06-24 |
| CVE-2026-52993 | tipc: fix double-free in tipc\_buf\_append() | critical | 9.8 | - | No | 2026-06-24 |
| CVE-2026-22770 | ImageMagick vulnerable to Release of Invalid Pointer in BilateralBlur when memory allocation fails | critical | 9.8 | - | No | 2026-01-20 |
| CVE-2023-54257 | net: macb: fix a memory corruption in extended buffer descriptor mode | critical | 9.8 | - | No | 2025-12-30 |
| CVE-2025-37935 | net: ethernet: mtk\_eth\_soc: fix SER panic with 4GB+ RAM | critical | 9.8 | - | No | 2025-05-20 |
| CVE-2024-44852 | - | critical | 9.8 | - | No | 2024-12-06 |
| CVE-2024-26953 | net: esp: fix bad handling of pages from page\_pool | critical | 9.8 | - | No | 2024-05-01 |
| CVE-2021-30473 | libaom: aom\_image.c in libaom frees memory that is not located on the heap | critical | 9.8 | - | No | 2021-05-06 |
| CVE-2021-24028 | - | critical | 9.8 | - | No | 2021-04-13 |
| CVE-2020-0103 | Remote code execution in System | critical | 9.8 | - | No | 2020-05-14 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-404](https://radicalnotion.ai/cwe/cwe-404) | Improper Resource Shutdown or Release |
| Child | [CWE-761](https://radicalnotion.ai/cwe/cwe-761) | Free of Pointer not at Start of Buffer |
| Child | [CWE-762](https://radicalnotion.ai/cwe/cwe-762) | Mismatched Memory Management Routines |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| Software Fault Patterns | Faulty Memory Release | SFP12 | - |

## Frequently asked questions

### What is CWE-763?

The product attempts to return a memory resource to the system, but it calls the wrong release function or calls the appropriate release function incorrectly.

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

184 recorded CVEs are attributed to CWE-763, including CVE-2026-88234, CVE-2026-74478 and CVE-2026-53000.

### How do you prevent CWE-763?

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-763 detected?

Fuzzing: Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

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

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

### Is CWE-763 actively exploited?

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

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

---

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