Skip to content

Commit

Permalink
Support usage when size = 0
Browse files Browse the repository at this point in the history
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. 😂
  • Loading branch information
fnlctrl committed Dec 18, 2016
1 parent bfac0ea commit e226f00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function pool(alloc, slice, size) {
var slab = null;
var offset = SIZE;
return function pool_alloc(size) {
if (size > MAX)
if (size > MAX || size === 0)
return alloc(size);
if (offset + size > SIZE) {
slab = alloc(SIZE);
Expand Down

0 comments on commit e226f00

Please sign in to comment.