aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 75010afb..de42d1e0 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2130,6 +2130,7 @@ LibraryManager.library = {
var fields = 0;
var argIndex = 0;
for (var formatIndex = 0; formatIndex < format.length; formatIndex++) {
+ if (next <= 0) return fields;
var next = get();
if (next <= 0) return fields; // End of input.
if (format[formatIndex] === '%') {
@@ -2153,7 +2154,8 @@ LibraryManager.library = {
(type === 'x' && (next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0) ||
next >= 'a'.charCodeAt(0) && next <= 'f'.charCodeAt(0) ||
next >= 'A'.charCodeAt(0) && next <= 'F'.charCodeAt(0))) ||
- (type === 's')) {
+ (type === 's') &&
+ (formatIndex >= format.length || next !== format[formatIndex].charCodeAt(0))) { // Stop when we read something that is coming up
buffer.push(String.fromCharCode(next));
next = get();
curr++;