Skip to content

Commit e226f00

Browse files
authored
Support usage when size = 0
I got an error when encoding an empty message (`{}`). When the message is empty, the size is 0 and `slab` is null, so`slice.call(slab, offset, offset += size);` gave me ``` Uncaught TypeError: Method get TypedArray.prototype.subarray called on incompatible receiver null ``` Adding this solved the issue for me. Please correct me if I was using it all wrong. 😂
1 parent bfac0ea commit e226f00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/util/pool/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function pool(alloc, slice, size) {
3434
var slab = null;
3535
var offset = SIZE;
3636
return function pool_alloc(size) {
37-
if (size > MAX)
37+
if (size > MAX || size === 0)
3838
return alloc(size);
3939
if (offset + size > SIZE) {
4040
slab = alloc(SIZE);

0 commit comments

Comments
 (0)