Message ID | 20240510091814.3172988-11-hadess@hadess.net (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Fix a number of static analysis issues | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | fail | WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 4: B1 Line exceeds max length (105>80): "bluez-5.75/src/main.c:451:2: alloc_arg: "parse_config_string" allocates memory that is stored into "str"." 5: B1 Line exceeds max length (135>80): "bluez-5.75/src/main.c:454:2: identity_transfer: Passing "str" as argument 1 to function "strtol", which sets "endptr" to that argument." 6: B1 Line exceeds max length (126>80): "bluez-5.75/src/main.c:456:3: noescape: Assuming resource "str" is not freed or pointed-to as ellipsis argument to "btd_error"." 7: B1 Line exceeds max length (113>80): "bluez-5.75/src/main.c:457:3: leaked_storage: Variable "endptr" going out of scope leaks the storage it points to." 8: B1 Line exceeds max length (110>80): "bluez-5.75/src/main.c:457:3: leaked_storage: Variable "str" going out of scope leaks the storage it points to." 9: B3 Line contains hard tab characters (\t): "455| if (!endptr || *endptr != '\0') {" 10: B3 Line contains hard tab characters (\t): "456| error("%s.%s = %s is not integer", group, key, str);" 11: B3 Line contains hard tab characters (\t): "457|-> return false;" 12: B3 Line contains hard tab characters (\t): "458| }" 16: B1 Line exceeds max length (105>80): "bluez-5.75/src/main.c:451:2: alloc_arg: "parse_config_string" allocates memory that is stored into "str"." 17: B1 Line exceeds max length (135>80): "bluez-5.75/src/main.c:454:2: identity_transfer: Passing "str" as argument 1 to function "strtol", which sets "endptr" to that argument." 18: B1 Line exceeds max length (113>80): "bluez-5.75/src/main.c:463:3: leaked_storage: Variable "endptr" going out of scope leaks the storage it points to." 19: B1 Line exceeds max length (110>80): "bluez-5.75/src/main.c:463:3: leaked_storage: Variable "str" going out of scope leaks the storage it points to." 20: B3 Line contains hard tab characters (\t): "461| warn("%s.%s = %zu is out of range (< %zu)", group, key, tmp," 21: B3 Line contains hard tab characters (\t): "462| min);" 22: B3 Line contains hard tab characters (\t): "463|-> return false;" 23: B3 Line contains hard tab characters (\t): "464| }" 27: B1 Line exceeds max length (105>80): "bluez-5.75/src/main.c:451:2: alloc_arg: "parse_config_string" allocates memory that is stored into "str"." 28: B1 Line exceeds max length (135>80): "bluez-5.75/src/main.c:454:2: identity_transfer: Passing "str" as argument 1 to function "strtol", which sets "endptr" to that argument." 29: B1 Line exceeds max length (113>80): "bluez-5.75/src/main.c:475:2: leaked_storage: Variable "endptr" going out of scope leaks the storage it points to." 30: B1 Line exceeds max length (110>80): "bluez-5.75/src/main.c:475:2: leaked_storage: Variable "str" going out of scope leaks the storage it points to." 31: B3 Line contains hard tab characters (\t): "473| *val = tmp;" 33: B3 Line contains hard tab characters (\t): "475|-> return true;" |
diff --git a/src/main.c b/src/main.c index 23af6781d931..ac840d684f6d 100644 --- a/src/main.c +++ b/src/main.c @@ -454,21 +454,25 @@ static bool parse_config_int(GKeyFile *config, const char *group, tmp = strtol(str, &endptr, 0); if (!endptr || *endptr != '\0') { error("%s.%s = %s is not integer", group, key, str); + g_free(str); return false; } if (tmp < min) { + g_free(str); warn("%s.%s = %zu is out of range (< %zu)", group, key, tmp, min); return false; } if (tmp > max) { + g_free(str); warn("%s.%s = %zu is out of range (> %zu)", group, key, tmp, max); return false; } + g_free(str); if (val) *val = tmp;