From 82592941fbb012a0581e63f3c22ceb5ae38a1026 Mon Sep 17 00:00:00 2001 From: Igor Sfiligoi Date: Sat, 23 Mar 2013 16:12:34 +0000 Subject: Better support for error in Chrome --- src/lib/rrdFile.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/lib') diff --git a/src/lib/rrdFile.js b/src/lib/rrdFile.js index 0f7c80d..81f7731 100644 --- a/src/lib/rrdFile.js +++ b/src/lib/rrdFile.js @@ -204,6 +204,8 @@ function RRDHeader(rrd_data) { // Internal, used for initialization RRDHeader.prototype.validate_rrd = function() { + if (this.rrd_data.getLength()<1) throw new InvalidRRD("Empty file."); + if (this.rrd_data.getLength()<16) throw new InvalidRRD("File too short."); if (this.rrd_data.getCStringAt(0,4)!=="RRD") throw new InvalidRRD("Wrong magic id."); this.rrd_version=this.rrd_data.getCStringAt(4,5); -- cgit v1.2.3-2-g168b