yaml / yaml/libyaml

Memory Leak in api.c

Open
#309 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.2k
Forks
370
PR merge metrics
No merged PRs in 30d

Description

Hey all,

I would like to report a memory leak detected with ASAN in api.c.

The leak can be trigged an input with invalid trailing UTF-8 octet, and one such input is attached.

input.txt

To reproduce, simply run ./tests/run-parser-test-suite input.txt after building with ASAN (CFLAGS="-fsanitize=address -g -O1")

The ASAN report will look like:

Parse error: invalid trailing UTF-8 octet

=================================================================
==3391==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 50176 byte(s) in 5 object(s) allocated from:
    #0 0x7ffff7682887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55555555bc75 in yaml_malloc /libyaml-asan/src/api.c:33

SUMMARY: AddressSanitizer: 50176 byte(s) leaked in 5 allocation(s).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in api.c and reproduce the leak with the attached input using ./tests/run-parser-test-suite input.txt after building with the stated ASAN flags. Trace the allocations reported by LeakSanitizer during the invalid trailing UTF-8 parse; done means this reproduction completes without the reported memory leak.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.