diff mbox series

Fix memory leak in parser/parser.c

Message ID 20241003143736.1160396-1-toertel@gmail.com
State Accepted
Headers show
Series Fix memory leak in parser/parser.c | expand

Commit Message

Mark Jonas Oct. 3, 2024, 2:36 p.m. UTC
From: Mark Jonas <toertel@gmail.com>

Reported-by: micro6947@gmail.com
Signed-off-by: Mark Jonas <toertel@gmail.com>
---
 parser/parser.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefano Babic Oct. 3, 2024, 6:43 p.m. UTC | #1
On 03.10.24 16:36, toertel@gmail.com wrote:
> From: Mark Jonas <toertel@gmail.com>
>
> Reported-by: micro6947@gmail.com
> Signed-off-by: Mark Jonas <toertel@gmail.com>
> ---
>   parser/parser.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/parser/parser.c b/parser/parser.c
> index 733df95c..f5113f94 100644
> --- a/parser/parser.c
> +++ b/parser/parser.c
> @@ -1159,6 +1159,7 @@ int parse_json(struct swupdate_cfg *swcfg, const char *filename, char **error)
>   	if (!cfg) {
>   		if (asprintf(error, "JSON File corrupted") == ENOMEM_ASPRINTF) {
>   			ERROR("OOM when caching error");
> +			free(string);
>   			return -ENOMEM;
>   		}
>   		free(string);

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/parser/parser.c b/parser/parser.c
index 733df95c..f5113f94 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -1159,6 +1159,7 @@  int parse_json(struct swupdate_cfg *swcfg, const char *filename, char **error)
 	if (!cfg) {
 		if (asprintf(error, "JSON File corrupted") == ENOMEM_ASPRINTF) {
 			ERROR("OOM when caching error");
+			free(string);
 			return -ENOMEM;
 		}
 		free(string);