Skip to content

Commit

Permalink
Discard very large buffers, they just cause problems, #132
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Mar 10, 2024
1 parent 288a906 commit 2550f79
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,14 @@ export class Packr extends Unpackr {
return packr.pack(value, encodeOptions)
}
packr.lastNamedStructuresLength = sharedLength
// don't keep large buffers around
if (target.length > 0x40000000) target = null
return returnBuffer
}
}
}
// don't keep large buffers around, they take too much memory and cause problems (limit at 1GB)
if (target.length > 0x40000000) target = null
if (encodeOptions & RESET_BUFFER_MODE)
position = start
}
Expand Down

0 comments on commit 2550f79

Please sign in to comment.