[Pkg-javascript-commits] [pdf.js] 15/116: Implement guards for stringToBytes and bytesToString

David Prévot taffit at moszumanska.debian.org
Fri Mar 6 16:19:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 6e99c29cf844c6bb57efef530328f63decd4db24
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Tue Dec 30 14:18:51 2014 +0100

    Implement guards for stringToBytes and bytesToString
---
 src/shared/util.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/shared/util.js b/src/shared/util.js
index 767f727..780af33 100644
--- a/src/shared/util.js
+++ b/src/shared/util.js
@@ -439,6 +439,8 @@ var XRefParseException = (function XRefParseExceptionClosure() {
 
 
 function bytesToString(bytes) {
+  assert(bytes !== null && typeof bytes === 'object' &&
+         bytes.length !== undefined, 'Invalid argument for bytesToString');
   var length = bytes.length;
   var MAX_ARGUMENT_COUNT = 8192;
   if (length < MAX_ARGUMENT_COUNT) {
@@ -454,6 +456,7 @@ function bytesToString(bytes) {
 }
 
 function stringToBytes(str) {
+  assert(typeof str === 'string', 'Invalid argument for stringToBytes');
   var length = str.length;
   var bytes = new Uint8Array(length);
   for (var i = 0; i < length; ++i) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list