Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak when using fy_path_expr_build_from_string #137

Open
rivit98 opened this issue Feb 1, 2025 · 0 comments
Open

memory leak when using fy_path_expr_build_from_string #137

rivit98 opened this issue Feb 1, 2025 · 0 comments

Comments

@rivit98
Copy link

rivit98 commented Feb 1, 2025

Hi, I found the following problem while fuzzing libfyaml

Code version

6e52e4d8b6adb01cc2fc377fab7b7fd523364438

How to reproduce

#include <stdio.h>
#include <libfyaml.h>

int main(int argc, char **argv) {
  char data[] = "\x7f\x00";
  struct fy_path_expr *expr = fy_path_expr_build_from_string(NULL, data, -1);
  fy_path_expr_free(expr);
}

compile & link with fuzzer support. Run and observe ASAN output:

==707088==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 208 byte(s) in 1 object(s) allocated from:
    #0 0x643982d9c313 in malloc (/home/rivit/workspace/fuzzing/libfyaml/build/nofuzz+0x1ad313) (BuildId: e82d9f92aaaaa63007d92dc146fc75c23f8429da)
    #1 0x643982f94c12 in fy_token_alloc_rl /home/rivit/workspace/fuzzing/libfyaml/src/lib/fy-token.h:164:9
    #2 0x643982f94c12 in fy_token_vcreate_rl /home/rivit/workspace/fuzzing/libfyaml/src/lib/fy-token.c:407:8

Indirect leak of 200 byte(s) in 1 object(s) allocated from:
    #0 0x643982d9c313 in malloc (/home/rivit/workspace/fuzzing/libfyaml/build/nofuzz+0x1ad313) (BuildId: e82d9f92aaaaa63007d92dc146fc75c23f8429da)
    #1 0x643982ea6c8d in fy_input_alloc /home/rivit/workspace/fuzzing/libfyaml/src/lib/fy-input.c:44:8

SUMMARY: AddressSanitizer: 408 byte(s) leaked in 2 allocation(s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant