Skip to content

Commit 08f1ddd

Browse files
author
Daniel Wirtz
committed
More information on capacity overflows
1 parent 75d3071 commit 08f1ddd

File tree

5 files changed

+67
-67
lines changed

5 files changed

+67
-67
lines changed

ByteBuffer.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@
554554
ByteBuffer.prototype.readInt8 = function(offset) {
555555
offset = typeof offset != 'undefined' ? offset : (this.offset+=1)-1;
556556
if (offset >= this.array.byteLength) {
557-
throw(new Error("Cannot read int8 from "+this+": Capacity overflow"));
557+
throw(new Error("Cannot read int8 from "+this+" at "+offset+": Capacity overflow"));
558558
}
559559
return this.view.getInt8(offset);
560560
};
@@ -603,8 +603,8 @@
603603
*/
604604
ByteBuffer.prototype.readUint8 = function(offset) {
605605
offset = typeof offset != 'undefined' ? offset : (this.offset+=1)-1;
606-
if (offset >= this.array.byteLength) {
607-
throw("Cannot read uint8 from "+this+": Capacity overflow");
606+
if (offset+1 > this.array.byteLength) {
607+
throw("Cannot read uint8 from "+this+" at "+offset+": Capacity overflow");
608608
}
609609
return this.view.getUint8(offset);
610610
};
@@ -633,7 +633,7 @@
633633
ByteBuffer.prototype.readInt16 = function(offset) {
634634
offset = typeof offset != 'undefined' ? offset : (this.offset+=2)-2;
635635
if (offset+2 > this.array.byteLength) {
636-
throw(new Error("Cannot read int16 from "+this+": Capacity overflow"));
636+
throw(new Error("Cannot read int16 from "+this+" at "+offset+": Capacity overflow"));
637637
}
638638
return this.view.getInt16(offset, this.littleEndian);
639639
};
@@ -682,7 +682,7 @@
682682
ByteBuffer.prototype.readUint16 = function(offset) {
683683
offset = typeof offset != 'undefined' ? offset : (this.offset+=2)-2;
684684
if (offset+2 > this.array.byteLEngth) {
685-
throw(new Error("Cannot read int16 from "+this+": Capacity overflow"));
685+
throw(new Error("Cannot read int16 from "+this+" at "+offset+": Capacity overflow"));
686686
}
687687
return this.view.getUint16(offset, this.littleEndian);
688688
};
@@ -711,7 +711,7 @@
711711
ByteBuffer.prototype.readInt32 = function(offset) {
712712
offset = typeof offset != 'undefined' ? offset : (this.offset+=4)-4;
713713
if (offset+4 > this.array.byteLength) {
714-
throw(new Error("Cannot read int32 from "+this+": Capacity overflow"));
714+
throw(new Error("Cannot read int32 from "+this+" at "+offset+": Capacity overflow"));
715715
}
716716
return this.view.getInt32(offset, this.littleEndian);
717717
};
@@ -760,7 +760,7 @@
760760
ByteBuffer.prototype.readUint32 = function(offset) {
761761
offset = typeof offset != 'undefined' ? offset : (this.offset+=4)-4;
762762
if (offset+4 > this.array.byteLength) {
763-
throw(new Error("Cannot read uint32 from "+this+": Capacity overflow"));
763+
throw(new Error("Cannot read uint32 from "+this+" at "+offset+": Capacity overflow"));
764764
}
765765
return this.view.getUint32(offset, this.littleEndian);
766766
};
@@ -789,7 +789,7 @@
789789
ByteBuffer.prototype.readFloat32 = function(offset) {
790790
offset = typeof offset != 'undefined' ? offset : (this.offset+=4)-4;
791791
if (this.array == null || offset+4 > this.array.byteLength) {
792-
throw(new Error("Cannot read float32 from "+this+": Capacity overflow"));
792+
throw(new Error("Cannot read float32 from "+this+" at "+offset+": Capacity overflow"));
793793
}
794794
return this.view.getFloat32(offset, this.littleEndian);
795795
};
@@ -838,7 +838,7 @@
838838
ByteBuffer.prototype.readFloat64 = function(offset) {
839839
offset = typeof offset != 'undefined' ? offset : (this.offset+=8)-8;
840840
if (this.array == null || offset+8 > this.array.byteLength) {
841-
throw(new Error("Cannot read float64 from "+this+": Capacity overflow"));
841+
throw(new Error("Cannot read float64 from "+this+" at "+offset+": Capacity overflow"));
842842
}
843843
return this.view.getFloat64(offset, this.littleEndian);
844844
};
@@ -903,7 +903,7 @@
903903
offset = typeof offset != 'undefined' ? offset : (this.offset+=8)-8;
904904
if (this.array == null || offset+8 > this.array.byteLength) {
905905
this.offset -= 8;
906-
throw(new Error("Cannot read int64 from "+this+": Capacity overflow"));
906+
throw(new Error("Cannot read int64 from "+this+" at "+offset+": Capacity overflow"));
907907
}
908908
var value;
909909
if (this.littleEndian) {
@@ -954,7 +954,7 @@
954954
offset = typeof offset != 'undefined' ? offset : (this.offset+=8)-8;
955955
if (this.array == null || offset+8 > this.array.byteLength) {
956956
this.offset -= 8;
957-
throw(new Error("Cannot read int64 from "+this+": Capacity overflow"));
957+
throw(new Error("Cannot read int64 from "+this+" at "+offset+": Capacity overflow"));
958958
}
959959
var value;
960960
if (this.littleEndian) {

0 commit comments

Comments
 (0)