diff --git a/index.es.js b/index.es.js index db06f8e..7701301 100644 --- a/index.es.js +++ b/index.es.js @@ -378,8 +378,10 @@ class SharedMap { this.stats.collisions++; /* Replacing existing key */ if (this._match(key, pos)) { - for (let i = 0; i < value.length; i++) + let i; + for (i = 0; i < value.length; i++) this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i); + this.valuesData[pos * this.meta[META.objSize] + i] = 0; exclusive || this._unlockLine(slidingLock); return; } diff --git a/index.js b/index.js index f6bf401..c0e2171 100644 --- a/index.js +++ b/index.js @@ -379,8 +379,10 @@ export default class SharedMap { this.stats.collisions++; /* Replacing existing key */ if (this._match(key, pos)) { - for (let i = 0; i < value.length; i++) + let i; + for (i = 0; i < value.length; i++) this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i); + this.valuesData[pos * this.meta[META.objSize] + i] = 0; exclusive || this._unlockLine(slidingLock); return; } diff --git a/index.umd.js b/index.umd.js index c101d20..13201b0 100644 --- a/index.umd.js +++ b/index.umd.js @@ -384,8 +384,10 @@ this.stats.collisions++; /* Replacing existing key */ if (this._match(key, pos)) { - for (let i = 0; i < value.length; i++) + let i; + for (i = 0; i < value.length; i++) this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i); + this.valuesData[pos * this.meta[META.objSize] + i] = 0; exclusive || this._unlockLine(slidingLock); return; }