Skip to content

Commit

Permalink
Pubnative: Fix Shared Memory Overwriting (prebid#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
guscarreon authored and shunj-nb committed Nov 8, 2022
1 parent 64170cd commit 92fb0d1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions adapters/pubnative/pubnative.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,35 @@ func convertImpression(imp *openrtb.Imp) error {
}
}
if imp.Banner != nil {
err := convertBanner(imp.Banner)
bannerCopy, err := convertBanner(imp.Banner)
if err != nil {
return err
}
imp.Banner = bannerCopy
}

return nil
}

// make sure that banner has openrtb 2.3-compatible size information
func convertBanner(banner *openrtb.Banner) error {
func convertBanner(banner *openrtb.Banner) (*openrtb.Banner, error) {
if banner.W == nil || banner.H == nil || *banner.W == 0 || *banner.H == 0 {
if len(banner.Format) > 0 {
f := banner.Format[0]
banner.W = &f.W
banner.H = &f.H

bannerCopy := *banner

bannerCopy.W = openrtb.Uint64Ptr(f.W)
bannerCopy.H = openrtb.Uint64Ptr(f.H)

return &bannerCopy, nil
} else {
return &errortypes.BadInput{
return nil, &errortypes.BadInput{
Message: "Size information missing for banner",
}
}
}
return nil
return banner, nil
}

func (a *PubnativeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
Expand Down

0 comments on commit 92fb0d1

Please sign in to comment.