Skip to content

Commit

Permalink
Store qualified rule name instead of Rule object from compiler callback
Browse files Browse the repository at this point in the history
Close: #142
  • Loading branch information
hillu committed Mar 24, 2024
1 parent 1a86fd9 commit f03acb3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ func compilerCallback(errorLevel C.int, filename *C.char, linenumber C.int, rule
Text: text,
}
if rule != nil {
// Rule object implicitly relies on the compiler object and is destroyed when the compiler is destroyed.
// Save a reference to the compiler to prevent that from happening.
msg.Rule = &Rule{cptr: rule, owner: c}
msg.Rule = C.GoString(rule_namespace(rule))

Check failure on line 49 in compiler.go

View workflow job for this annotation

GitHub Actions / buildtest

undefined: rule_namespace
if msg.Rule == "default" {
msg.Rule = C.GoString(C.rule_identifier(rule))
} else {
msg.Rule += "." + C.GoString(C.rule_identifier(rule))
}
}
switch errorLevel {
case C.YARA_ERROR_LEVEL_ERROR:
Expand Down Expand Up @@ -78,7 +81,7 @@ type CompilerMessage struct {
Filename string
Line int
Text string
Rule *Rule
Rule string
}

// NewCompiler creates a YARA compiler.
Expand Down

0 comments on commit f03acb3

Please sign in to comment.