Skip to content

Commit e59ef5d

Browse files
committed
chore: fix jsonblob memory usage
Signed-off-by: Ludovic Cleroux <[email protected]>
1 parent fedb9d3 commit e59ef5d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

libvuln/jsonblob/jsonblob.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func (l *Loader) Next() bool {
7373
return false
7474
}
7575

76-
var vs []claircore.Vulnerability
7776
for l.err = l.dec.Decode(&l.de); l.err == nil; l.err = l.dec.Decode(&l.de) {
7877
id := l.de.Ref
7978
// If we just hit a new Entry, promote the current one.
@@ -84,15 +83,14 @@ func (l *Loader) Next() bool {
8483
l.next.Fingerprint = l.de.Fingerprint
8584
l.next.Date = l.de.Date
8685
}
87-
i := len(vs)
8886
switch l.de.Kind {
8987
case driver.VulnerabilityKind:
90-
vs = append(vs, claircore.Vulnerability{})
91-
if err := json.Unmarshal(l.de.Vuln.buf, &vs[i]); err != nil {
88+
vuln := claircore.Vulnerability{}
89+
if err := json.Unmarshal(l.de.Vuln.buf, &vuln); err != nil {
9290
l.err = err
9391
return false
9492
}
95-
l.next.Vuln = append(l.next.Vuln, &vs[i])
93+
l.next.Vuln = append(l.next.Vuln, &vuln)
9694
case driver.EnrichmentKind:
9795
en := driver.EnrichmentRecord{}
9896
if err := json.Unmarshal(l.de.Enrichment.buf, &en); err != nil {

0 commit comments

Comments
 (0)