diff --git a/libraries/libapparmor/src/grammar.y b/libraries/libapparmor/src/grammar.y
index 40bac9193..23f746169 100644
--- a/libraries/libapparmor/src/grammar.y
+++ b/libraries/libapparmor/src/grammar.y
@@ -15,6 +15,12 @@
* along with this program. If not, see .
*/
+/* aalogparse_error now requires visibility of the aa_log_record type
+ * Also include in a %code requires block to add it to the header
+ */
+%code requires{
+ #include
+}
%{
@@ -41,12 +47,10 @@
#define debug_unused_ unused_
#endif
-aa_log_record *ret_record;
-
/* Since we're a library, on any errors we don't want to print out any
* error messages. We should probably add a debug interface that does
* emit messages when asked for. */
-void aalogparse_error(unused_ void *scanner, debug_unused_ char const *s)
+void aalogparse_error(unused_ void *scanner, aa_log_record *ret_record, debug_unused_ char const *s)
{
#if (YYDEBUG != 0)
printf("ERROR: %s\n", s);
@@ -89,9 +93,10 @@ aa_record_event_type lookup_aa_event(unsigned int type)
%define parse.trace
*/
-%define api.pure
+%define api.pure full
%lex-param{void *scanner}
%parse-param{void *scanner}
+%parse-param{aa_log_record *ret_record}
%union
{
@@ -284,8 +289,9 @@ audit_user_msg: TOK_KEY_MSG TOK_EQUALS audit_id audit_user_msg_tail
audit_id: TOK_AUDIT TOK_OPEN_PAREN TOK_AUDIT_DIGITS TOK_PERIOD TOK_AUDIT_DIGITS TOK_COLON TOK_AUDIT_DIGITS TOK_CLOSE_PAREN TOK_COLON
{
- if (!asprintf(&ret_record->audit_id, "%s.%s:%s", $3, $5, $7))
- yyerror(scanner, YY_("Out of memory"));
+ if (!asprintf(&ret_record->audit_id, "%s.%s:%s", $3, $5, $7)) {
+ yyerror(scanner, ret_record, YY_("Out of memory"));
+ }
ret_record->epoch = atol($3);
ret_record->audit_sub_id = atoi($7);
free($3);
@@ -485,8 +491,7 @@ _parse_yacc(char *str)
YY_BUFFER_STATE lex_buf;
yyscan_t scanner;
- ret_record = NULL;
- ret_record = malloc(sizeof(aa_log_record));
+ aa_log_record *ret_record = malloc(sizeof(aa_log_record));
_init_log_record(ret_record);
@@ -502,7 +507,7 @@ _parse_yacc(char *str)
aalogparse_lex_init_extra(&string_buf, &scanner);
lex_buf = aalogparse__scan_string(str, scanner);
/* Ignore return value to return an AA_RECORD_INVALID event */
- (void)aalogparse_parse(scanner);
+ (void)aalogparse_parse(scanner, ret_record);
aalogparse__delete_buffer(lex_buf, scanner);
aalogparse_lex_destroy(scanner);
// free(NULL) is a no-op