Skip to content

Commit

Permalink
Merge pull request #64 from realPy/master
Browse files Browse the repository at this point in the history
Add 4 bytes padding to avoid crash on 32 bit system with misalign struct
  • Loading branch information
elsigh authored Aug 26, 2019
2 parents ac4b801 + 489eff7 commit daf92ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions uaparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type RegexesDefinitions struct {
UA []*uaParser `yaml:"user_agent_parsers"`
OS []*osParser `yaml:"os_parsers"`
Device []*deviceParser `yaml:"device_parsers"`
_ [4]byte // padding for alignment
sync.RWMutex

}

type UserAgentSorter []*uaParser
Expand All @@ -32,6 +34,7 @@ type uaParser struct {
V1Replacement string `yaml:"v1_replacement"`
V2Replacement string `yaml:"v2_replacement"`
V3Replacement string `yaml:"v3_replacement"`
_ [4]byte // padding for alignment
MatchesCount uint64
}

Expand Down Expand Up @@ -64,6 +67,7 @@ type osParser struct {
V2Replacement string `yaml:"os_v2_replacement"`
V3Replacement string `yaml:"os_v3_replacement"`
V4Replacement string `yaml:"os_v4_replacement"`
_ [4]byte // padding for alignment
MatchesCount uint64
}

Expand Down Expand Up @@ -97,6 +101,7 @@ type deviceParser struct {
DeviceReplacement string `yaml:"device_replacement"`
BrandReplacement string `yaml:"brand_replacement"`
ModelReplacement string `yaml:"model_replacement"`
_ [4]byte // padding for alignment
MatchesCount uint64
}

Expand Down

0 comments on commit daf92ba

Please sign in to comment.