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 in print_table_for_refs() #4224

Closed
setharnold opened this issue Apr 15, 2021 · 0 comments · Fixed by #4225
Closed

Memory leak in print_table_for_refs() #4224

setharnold opened this issue Apr 15, 2021 · 0 comments · Fixed by #4225

Comments

@setharnold
Copy link

Hello, I'm giving flatpak a very quick review as part of the Ubuntu main inclusion process. This is just a quick look, not a full audit.

return FALSE;

Coverity has marked the print_table_for_refs() function as leaking the printer variable if the flatpak_split_partial_ref_arg() test fails and the function returns FALSE:

app/flatpak-builtins-list.c:143
  Type: Resource leak (RESOURCE_LEAK)

app/flatpak-builtins-list.c:131:
  1. path: Condition "columns[0].name == NULL", taking false branch.
app/flatpak-builtins-list.c:134:
  2. alloc_fn: Storage is returned from allocation function "flatpak_table_printer_new".
app/flatpak-table-printer.c:97:
  2.1. path: Condition "__s == 1", taking false branch.
app/flatpak-table-printer.c:97:
  2.2. path: Condition "0", taking false branch.
app/flatpak-table-printer.c:97:
  2.3. alloc_fn: Storage is returned from allocation function "g_malloc0_n".
app/flatpak-table-printer.c:97:
  2.4. assign: Assigning: "__p" = "g_malloc0_n(__n, __s)".
app/flatpak-table-printer.c:97:
  2.5. assign: Assigning: "printer" = "(FlatpakTablePrinter *)({...; __p;})".
app/flatpak-table-printer.c:104:
  2.6. return_alloc: Returning allocated memory "printer".
app/flatpak-builtins-list.c:134:
  3. var_assign: Assigning: "printer" = storage returned from "flatpak_table_printer_new()".
app/flatpak-builtins-list.c:136:
  4. path: Condition "opt_cols == NULL", taking true branch.
app/flatpak-builtins-list.c:136:
  5. path: Condition "!opt_show_details", taking true branch.
app/flatpak-builtins-list.c:136:
  6. noescape: Resource "printer" is not freed or pointed-to in "flatpak_table_printer_set_columns".
app/flatpak-table-printer.c:157:
  6.1. noescape: "flatpak_table_printer_set_columns(FlatpakTablePrinter *, Column *, gboolean)" does not free or save its parameter "printer".
app/flatpak-builtins-list.c:139:
  7. path: Condition "app_runtime", taking true branch.
app/flatpak-builtins-list.c:141:
  8. path: Condition "!flatpak_split_partial_ref_arg(app_runtime, FLATPAK_KINDS_RUNTIME, NULL, NULL, &match_kinds, &match_id, &match_arch, &match_branch, error)", taking true branch.
app/flatpak-builtins-list.c:143:
  9. leaked_storage: Variable "printer" going out of scope leaks the storage it points to.

Thanks

smcv added a commit to smcv/flatpak that referenced this issue Apr 15, 2021
alexlarsson pushed a commit that referenced this issue Apr 16, 2021
debarshiray pushed a commit to debarshiray/flatpak that referenced this issue Jun 2, 2022
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

Successfully merging a pull request may close this issue.

1 participant