Commit e8afb6d8 authored by Devon H. O'Dell's avatar Devon H. O'Dell Committed by Russ Cox

cgo: Only allow numeric / string / character type constants for references

to #defined things.

Fixes #520.

R=rsc, rsaarelm
CC=golang-dev
https://golang.org/cl/186138
parent c6336155
......@@ -48,7 +48,13 @@ func (p *Prog) loadDebugInfo() {
val = strings.TrimSpace(line[tabIndex:])
}
defines[key] = val
// Only allow string, character, and numeric constants. Ignoring #defines for
// symbols allows those symbols to be referenced in Go, as they will be
// translated by gcc later.
_, err := strconv.Atoi(string(val[0]))
if err == nil || val[0] == '\'' || val[0] == '"' {
defines[key] = val
}
}
// Construct a slice of unique names from p.Crefs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment