mirror of https://github.com/yshui/picom.git
Fix memory errors reported by `scan-build`.
- Fix non-critical memory-leak in `picom.c` and `options.c` where we don't free all allocated memory before dieing. - Explicitly allocate new branch in `c2.c` to silence false-positive memory-leak.
This commit is contained in:
parent
3576a92da3
commit
337831e094
3
src/c2.c
3
src/c2.c
|
@ -265,7 +265,8 @@ static inline void c2_ptr_reset(c2_ptr_t *pp) {
|
||||||
* Combine two condition trees.
|
* Combine two condition trees.
|
||||||
*/
|
*/
|
||||||
static inline c2_ptr_t c2h_comb_tree(c2_b_op_t op, c2_ptr_t p1, c2_ptr_t p2) {
|
static inline c2_ptr_t c2h_comb_tree(c2_b_op_t op, c2_ptr_t p1, c2_ptr_t p2) {
|
||||||
c2_ptr_t p = {.isbranch = true, .b = cmalloc(c2_b_t)};
|
c2_ptr_t p = {.isbranch = true, .b = NULL};
|
||||||
|
p.b = cmalloc(c2_b_t);
|
||||||
|
|
||||||
p.b->neg = false;
|
p.b->neg = false;
|
||||||
p.b->op = op;
|
p.b->op = op;
|
||||||
|
|
|
@ -521,6 +521,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
|
|
||||||
// Parse commandline arguments. Range checking will be done later.
|
// Parse commandline arguments. Range checking will be done later.
|
||||||
|
|
||||||
|
bool failed = false;
|
||||||
const char *deprecation_message attr_unused =
|
const char *deprecation_message attr_unused =
|
||||||
"has been removed. If you encounter problems "
|
"has been removed. If you encounter problems "
|
||||||
"without this feature, please feel free to "
|
"without this feature, please feel free to "
|
||||||
|
@ -567,11 +568,11 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
case 'C':
|
case 'C':
|
||||||
log_error("Option `--no-dock-shadow`/`-C` has been removed. Please"
|
log_error("Option `--no-dock-shadow`/`-C` has been removed. Please"
|
||||||
" use the wintype option `shadow` of `dock` instead.");
|
" use the wintype option `shadow` of `dock` instead.");
|
||||||
return false;
|
failed = true; break;
|
||||||
case 'G':
|
case 'G':
|
||||||
log_error("Option `--no-dnd-shadow`/`-G` has been removed. Please "
|
log_error("Option `--no-dnd-shadow`/`-G` has been removed. Please "
|
||||||
"use the wintype option `shadow` of `dnd` instead.");
|
"use the wintype option `shadow` of `dnd` instead.");
|
||||||
return false;
|
failed = true; break;
|
||||||
case 'm':;
|
case 'm':;
|
||||||
double tmp;
|
double tmp;
|
||||||
tmp = normalize_d(atof(optarg));
|
tmp = normalize_d(atof(optarg));
|
||||||
|
@ -604,7 +605,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
case 'a':
|
case 'a':
|
||||||
case 's':
|
case 's':
|
||||||
log_error("-n, -a, and -s have been removed.");
|
log_error("-n, -a, and -s have been removed.");
|
||||||
return false;
|
failed = true; break;
|
||||||
// Long options
|
// Long options
|
||||||
case 256:
|
case 256:
|
||||||
// --config
|
// --config
|
||||||
|
@ -660,12 +661,14 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
// --alpha-step
|
// --alpha-step
|
||||||
log_error("--alpha-step has been removed, we now tries to "
|
log_error("--alpha-step has been removed, we now tries to "
|
||||||
"make use of all alpha values");
|
"make use of all alpha values");
|
||||||
return false;
|
failed = true; break;
|
||||||
case 272: log_error("use of --dbe is deprecated"); return false;
|
case 272:
|
||||||
|
log_error("--dbe has been removed");
|
||||||
|
failed = true; break;
|
||||||
case 273:
|
case 273:
|
||||||
log_error("--paint-on-overlay has been removed, the feature is enabled "
|
log_error("--paint-on-overlay has been removed, the feature is enabled "
|
||||||
"whenever possible");
|
"whenever possible");
|
||||||
return false;
|
failed = true; break;
|
||||||
P_CASEBOOL(274, sw_opti);
|
P_CASEBOOL(274, sw_opti);
|
||||||
case 275:
|
case 275:
|
||||||
// --vsync-aggressive
|
// --vsync-aggressive
|
||||||
|
@ -805,7 +808,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
case 312:
|
case 312:
|
||||||
// --xrender-sync
|
// --xrender-sync
|
||||||
log_error("Please use --xrender-sync-fence instead of --xrender-sync");
|
log_error("Please use --xrender-sync-fence instead of --xrender-sync");
|
||||||
return false;
|
failed = true; break;
|
||||||
P_CASEBOOL(313, xrender_sync_fence);
|
P_CASEBOOL(313, xrender_sync_fence);
|
||||||
P_CASEBOOL(315, no_fading_destroyed_argb);
|
P_CASEBOOL(315, no_fading_destroyed_argb);
|
||||||
P_CASEBOOL(316, force_win_blend);
|
P_CASEBOOL(316, force_win_blend);
|
||||||
|
@ -866,12 +869,21 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
#undef P_CASEBOOL
|
#undef P_CASEBOOL
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
// Parsing this option has failed, break the loop
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore LC_NUMERIC
|
// Restore LC_NUMERIC
|
||||||
setlocale(LC_NUMERIC, lc_numeric_old);
|
setlocale(LC_NUMERIC, lc_numeric_old);
|
||||||
free(lc_numeric_old);
|
free(lc_numeric_old);
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (opt->monitor_repaint && opt->backend != BKEND_XRENDER &&
|
if (opt->monitor_repaint && opt->backend != BKEND_XRENDER &&
|
||||||
!opt->experimental_backends) {
|
!opt->experimental_backends) {
|
||||||
log_warn("--monitor-repaint has no effect when backend is not xrender");
|
log_warn("--monitor-repaint has no effect when backend is not xrender");
|
||||||
|
|
|
@ -2515,6 +2515,7 @@ int main(int argc, char **argv) {
|
||||||
if (pid_file) {
|
if (pid_file) {
|
||||||
log_trace("remove pid file %s", pid_file);
|
log_trace("remove pid file %s", pid_file);
|
||||||
unlink(pid_file);
|
unlink(pid_file);
|
||||||
|
free(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_deinit_tls();
|
log_deinit_tls();
|
||||||
|
|
Loading…
Reference in New Issue