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 3bf5f65592e42e7a0506e8039cdcd643bf5bd8a5

Fix a possible leak on formatting tab line
3 clines weren't properly managed. On success they were all
used/released, but in some cases the memory could leak.

Discovered by Coverity.
Author: xaizek
Author date (UTC): 2025-04-28 13:40
Committer name: xaizek
Committer date (UTC): 2025-05-02 07:58
Parent(s): e29b09f93972802bf3ed7a2a1a016c82e9b3bace
Signing key: 99DC5E4DB05F6BE2
Tree: 952dee7c5cab6df79930705c02155f271ab1d7e1
File Lines added Lines deleted
ChangeLog 2 0
src/ui/colored_line.c 13 0
src/ui/colored_line.h 3 0
src/ui/ui.c 5 1
File ChangeLog changed (mode: 100644) (index d28071ff9..870a9d272)
61 61 Fixed ruler in menu mode not growing in size to accomodate its content. Fixed ruler in menu mode not growing in size to accomodate its content.
62 62 Thanks to CaptainFantastic. Thanks to CaptainFantastic.
63 63
64 Fixed a memory leak on formatting tab line when there is not enough space.
65
64 66 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
65 67
66 68 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
File src/ui/colored_line.c changed (mode: 100644) (index 4e94cbcee..154af8ad6)
... ... cline_left_ellipsis(cline_t *cline, size_t max_width, const char ell[])
212 212 strprepend(&cline->attrs, &cline->attrs_len, spaces); strprepend(&cline->attrs, &cline->attrs_len, spaces);
213 213 } }
214 214
215 cline_t
216 cline_steal(cline_t *cline)
217 {
218 cline_t result = *cline;
219
220 cline->line = NULL;
221 cline->line_len = 0;
222 cline->attrs = NULL;
223 cline->attrs_len = 0;
224
225 return result;
226 }
227
215 228 void void
216 229 cline_dispose(cline_t *cline) cline_dispose(cline_t *cline)
217 230 { {
File src/ui/colored_line.h changed (mode: 100644) (index c90c7869d..33d85dce9)
... ... void cline_print(const cline_t *cline, WINDOW *win,
76 76 * needed. */ * needed. */
77 77 void cline_left_ellipsis(cline_t *cline, size_t max_width, const char ell[]); void cline_left_ellipsis(cline_t *cline, size_t max_width, const char ell[]);
78 78
79 /* Copies the fields and clears the passed in cline. */
80 cline_t cline_steal(cline_t *cline);
81
79 82 /* Frees all resources allocated by cline. The parameter can't be NULL. */ /* Frees all resources allocated by cline. The parameter can't be NULL. */
80 83 void cline_dispose(cline_t *cline); void cline_dispose(cline_t *cline);
81 84
File src/ui/ui.c changed (mode: 100644) (index 73e72f799..538173942)
... ... format_tab_labels(view_t *view, int max_width, path_func pf)
2384 2384 cline_t *tab_label = DA_EXTEND(tab_labels); cline_t *tab_label = DA_EXTEND(tab_labels);
2385 2385 if(tab_label != NULL) if(tab_label != NULL)
2386 2386 { {
2387 *tab_label = prefix;
2387 *tab_label = cline_steal(&prefix);
2388 2388 cline_append(tab_label, &title); cline_append(tab_label, &title);
2389 2389 cline_append(tab_label, &suffix); cline_append(tab_label, &suffix);
2390 2390 DA_COMMIT(tab_labels); DA_COMMIT(tab_labels);
 
... ... format_tab_labels(view_t *view, int max_width, path_func pf)
2392 2392 } }
2393 2393
2394 2394 width_used += real_width; width_used += real_width;
2395
2396 cline_dispose(&prefix);
2397 cline_dispose(&title);
2398 cline_dispose(&suffix);
2395 2399 } }
2396 2400
2397 2401 tab_line_info_t result = { tab_line_info_t result = {
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