From 75c3590741ae0f210d2aa9310c84f73f94fb0f63 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 31 Jan 2022 00:44:29 +0100 Subject: [PATCH] [parsers] Use YYABORT instead of negative return Seems return could lead to a memleak of yymsg --- src/parsers/daap_parser.y | 4 ++-- src/parsers/rsp_parser.y | 2 +- src/parsers/smartpl_parser.y | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/parsers/daap_parser.y b/src/parsers/daap_parser.y index 63bd0b0f..3c9109d0 100644 --- a/src/parsers/daap_parser.y +++ b/src/parsers/daap_parser.y @@ -425,8 +425,8 @@ static int result_set(struct daap_result *result, struct ast *a) %% query: - expr { return result_set(result, $1); } -| expr DAAP_T_NEWLINE { return result_set(result, $1); } + expr { if (result_set(result, $1) < 0) YYABORT; } +| expr DAAP_T_NEWLINE { if (result_set(result, $1) < 0) YYABORT; } ; expr: diff --git a/src/parsers/rsp_parser.y b/src/parsers/rsp_parser.y index a6c118c8..f86645dc 100644 --- a/src/parsers/rsp_parser.y +++ b/src/parsers/rsp_parser.y @@ -398,7 +398,7 @@ static int result_set(struct rsp_result *result, struct ast *a) %% query: - criteria { return result_set(result, $1); } + criteria { if (result_set(result, $1) < 0) YYABORT; } ; criteria: criteria RSP_T_AND criteria { $$ = ast_new(RSP_T_AND, $1, $3); } diff --git a/src/parsers/smartpl_parser.y b/src/parsers/smartpl_parser.y index 8982e598..69747c39 100644 --- a/src/parsers/smartpl_parser.y +++ b/src/parsers/smartpl_parser.y @@ -542,14 +542,14 @@ static int result_set(struct smartpl_result *result, char *title, struct ast *cr %% playlist: - SMARTPL_T_STRING '{' criteria having order limit '}' { return result_set(result, $1, $3, $4, $5, $6); } -| SMARTPL_T_STRING '{' criteria having order '}' { return result_set(result, $1, $3, $4, $5, NULL); } -| SMARTPL_T_STRING '{' criteria having limit '}' { return result_set(result, $1, $3, $4, NULL, $5); } -| SMARTPL_T_STRING '{' criteria having '}' { return result_set(result, $1, $3, $4, NULL, NULL); } -| SMARTPL_T_STRING '{' criteria order limit '}' { return result_set(result, $1, $3, NULL, $4, $5); } -| SMARTPL_T_STRING '{' criteria order '}' { return result_set(result, $1, $3, NULL, $4, NULL); } -| SMARTPL_T_STRING '{' criteria limit '}' { return result_set(result, $1, $3, NULL, NULL, $4); } -| SMARTPL_T_STRING '{' criteria '}' { return result_set(result, $1, $3, NULL, NULL, NULL); } + SMARTPL_T_STRING '{' criteria having order limit '}' { if (result_set(result, $1, $3, $4, $5, $6) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria having order '}' { if (result_set(result, $1, $3, $4, $5, NULL) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria having limit '}' { if (result_set(result, $1, $3, $4, NULL, $5) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria having '}' { if (result_set(result, $1, $3, $4, NULL, NULL) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria order limit '}' { if (result_set(result, $1, $3, NULL, $4, $5) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria order '}' { if (result_set(result, $1, $3, NULL, $4, NULL) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria limit '}' { if (result_set(result, $1, $3, NULL, NULL, $4) < 0) YYABORT; } +| SMARTPL_T_STRING '{' criteria '}' { if (result_set(result, $1, $3, NULL, NULL, NULL) < 0) YYABORT; } ; criteria: criteria SMARTPL_T_AND criteria { $$ = ast_new(SMARTPL_T_AND, $1, $3); }