Skip to content

Leak of FILE descriptor and using nullptr in memset #11888

@safocl

Description

@safocl

Operating System Info

Other

Other OS

Archlinux

OBS Studio Version

31.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://0x0.st/8TfN.txt

OBS Studio Crash Log URL

No response

Expected Behavior

Not leak of FILE descriptor and do not using nullptr in memset (defined behavior).

Current Behavior

Leak of FILE descriptor and using nullptr in memset (undefined behavior).

Steps to Reproduce

  1. Compile

Anything else we should know?

memset(data, '\0', file_size);

but malloc can return nullptr:
data = (utf8_char_t*)malloc(1 + file_size);

https://en.cppreference.com/w/c/string/byte/memset

The behavior is undefined if dest is a null pointer.

FILE* file = fopen(path, "r");

FILE is closed in the if closure only:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions