mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-11 00:18:29 +00:00
Fix memleak in if_match
This commit is contained in:
parent
d6ea46f8cb
commit
a1a73c23cb
@ -195,6 +195,8 @@ int compare(const char *expr)
|
|||||||
char *expr_dup;
|
char *expr_dup;
|
||||||
int idx, mtype;
|
int idx, mtype;
|
||||||
enum arg_type type1, type2;
|
enum arg_type type1, type2;
|
||||||
|
long lng_a, lng_b;
|
||||||
|
double dbl_a, dbl_b;
|
||||||
|
|
||||||
idx = find_match_op(expr);
|
idx = find_match_op(expr);
|
||||||
mtype = get_match_type(expr);
|
mtype = get_match_type(expr);
|
||||||
@ -213,6 +215,7 @@ int compare(const char *expr)
|
|||||||
type2 = get_arg_type(expr_dup + idx + 1);
|
type2 = get_arg_type(expr_dup + idx + 1);
|
||||||
if (type1 == ARG_BAD || type2 == ARG_BAD) {
|
if (type1 == ARG_BAD || type2 == ARG_BAD) {
|
||||||
NORM_ERR("Bad arguments: '%s' and '%s'", expr_dup, (expr_dup + idx + 1));
|
NORM_ERR("Bad arguments: '%s' and '%s'", expr_dup, (expr_dup + idx + 1));
|
||||||
|
free(expr_dup);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (type1 == ARG_LONG && type2 == ARG_DOUBLE)
|
if (type1 == ARG_LONG && type2 == ARG_DOUBLE)
|
||||||
@ -222,6 +225,7 @@ int compare(const char *expr)
|
|||||||
if (type1 != type2) {
|
if (type1 != type2) {
|
||||||
NORM_ERR("trying to compare args '%s' and '%s' of different type",
|
NORM_ERR("trying to compare args '%s' and '%s' of different type",
|
||||||
expr_dup, (expr_dup + idx + 1));
|
expr_dup, (expr_dup + idx + 1));
|
||||||
|
free(expr_dup);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
switch (type1) {
|
switch (type1) {
|
||||||
@ -233,17 +237,23 @@ int compare(const char *expr)
|
|||||||
idx = scompare(a, (enum match_type) mtype, b);
|
idx = scompare(a, (enum match_type) mtype, b);
|
||||||
free(a);
|
free(a);
|
||||||
free(b);
|
free(b);
|
||||||
|
free(expr_dup);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
case ARG_LONG:
|
case ARG_LONG:
|
||||||
return lcompare(arg_to_long(expr_dup), (enum match_type) mtype,
|
lng_a = arg_to_long(expr_dup);
|
||||||
arg_to_long(expr_dup + idx + 1));
|
lng_b = arg_to_long(expr_dup + idx + 1);
|
||||||
|
free(expr_dup);
|
||||||
|
return lcompare(lng_a, (enum match_type) mtype, lng_b);
|
||||||
case ARG_DOUBLE:
|
case ARG_DOUBLE:
|
||||||
return dcompare(arg_to_double(expr_dup), (enum match_type) mtype,
|
dbl_a = arg_to_double(expr_dup);
|
||||||
arg_to_double(expr_dup + idx + 1));
|
dbl_b = arg_to_double(expr_dup + idx + 1);
|
||||||
|
free(expr_dup);
|
||||||
|
return dcompare(dbl_a, (enum match_type) mtype, dbl_b);
|
||||||
case ARG_BAD: /* make_gcc_happy() */;
|
case ARG_BAD: /* make_gcc_happy() */;
|
||||||
}
|
}
|
||||||
/* not reached */
|
/* not reached */
|
||||||
|
free(expr_dup);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user