Просмотр исходного кода

Don't attempt to get/set index when no buffer was written yet

phoboslab 7 лет назад
Родитель
Сommit
7b909ef2c5
2 измененных файлов: 18 добавлений и 0 удалений
  1. 9 0
      src/mp2-wasm.js
  2. 9 0
      src/mpeg1-wasm.js

+ 9 - 0
src/mp2-wasm.js Просмотреть файл

@@ -31,14 +31,23 @@ MP2WASM.prototype.initializeWasmDecoder = function() {
31 31
 };
32 32
 
33 33
 MP2WASM.prototype.destroy = function() {
34
+	if (!this.decoder) {
35
+		return;
36
+	}
34 37
 	this.functions._mp2_decoder_destroy(this.decoder);
35 38
 };
36 39
 
37 40
 MP2WASM.prototype.bufferGetIndex = function() {
41
+	if (!this.decoder) {
42
+		return;
43
+	}
38 44
 	return this.functions._mp2_decoder_get_index(this.decoder);
39 45
 };
40 46
 
41 47
 MP2WASM.prototype.bufferSetIndex = function(index) {
48
+	if (!this.decoder) {
49
+		return;
50
+	}
42 51
 	this.functions._mp2_decoder_set_index(this.decoder, index);
43 52
 };
44 53
 

+ 9 - 0
src/mpeg1-wasm.js Просмотреть файл

@@ -29,14 +29,23 @@ MPEG1WASM.prototype.initializeWasmDecoder = function() {
29 29
 };
30 30
 
31 31
 MPEG1WASM.prototype.destroy = function() {
32
+	if (!this.decoder) {
33
+		return;
34
+	}
32 35
 	this.functions._mpeg1_decoder_destroy(this.decoder);
33 36
 };
34 37
 
35 38
 MPEG1WASM.prototype.bufferGetIndex = function() {
39
+	if (!this.decoder) {
40
+		return;
41
+	}
36 42
 	return this.functions._mpeg1_decoder_get_index(this.decoder);
37 43
 };
38 44
 
39 45
 MPEG1WASM.prototype.bufferSetIndex = function(index) {
46
+	if (!this.decoder) {
47
+		return;
48
+	}
40 49
 	this.functions._mpeg1_decoder_set_index(this.decoder, index);
41 50
 };
42 51