xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit d31c0d16433989b6011196ceff8399ad36b3e909

Make filetype.c:add_assoc() free assoc on error
That's how the code was using the function, even if it never actually
did that.
Author: xaizek
Author date (UTC): 2025-07-10 16:18
Committer name: xaizek
Committer date (UTC): 2025-07-10 16:18
Parent(s): c4ef96dfc40aba8aeb1c9a13413107b00b431d41
Signing key: 99DC5E4DB05F6BE2
Tree: 515f44d7d6a86d9160a04616aeddb8173f194ee4
File Lines added Lines deleted
src/filetype.c 4 1
File src/filetype.c changed (mode: 100644) (index 87cfb65aa..0aaba1863)
... ... ft_set_viewers(matchers_t *matchers, const char viewers[])
287 287 }; };
288 288 ft_assoc_records_free(&view_records); ft_assoc_records_free(&view_records);
289 289
290 /* On error, add_assoc() frees assoc, so just exit then. */
290 291 (void)add_assoc(&fileviewers, assoc); (void)add_assoc(&fileviewers, assoc);
291 292 } }
292 293
 
... ... clone_assoc_records(const assoc_records_t *records, const char pattern[],
311 312 } }
312 313
313 314 /* Adds association to the list of associations. Returns non-zero on /* Adds association to the list of associations. Returns non-zero on
314 * out of memory error, otherwise zero is returned. */
315 * out of memory error, otherwise zero is returned. Frees resources of assoc
316 * on error. */
315 317 static int static int
316 318 add_assoc(assoc_list_t *assoc_list, assoc_t assoc) add_assoc(assoc_list_t *assoc_list, assoc_t assoc)
317 319 { {
 
... ... add_assoc(assoc_list_t *assoc_list, assoc_t assoc)
319 321 p = reallocarray(assoc_list->list, assoc_list->count + 1, sizeof(assoc_t)); p = reallocarray(assoc_list->list, assoc_list->count + 1, sizeof(assoc_t));
320 322 if(p == NULL) if(p == NULL)
321 323 { {
324 free_assoc(&assoc);
322 325 show_error_msg("Memory Error", "Unable to allocate enough memory"); show_error_msg("Memory Error", "Unable to allocate enough memory");
323 326 return 1; return 1;
324 327 } }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master