aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/preamble.js3
-rw-r--r--tests/files.cpp3
2 files changed, 3 insertions, 3 deletions
diff --git a/src/preamble.js b/src/preamble.js
index e7cbcce6..8cf87bfd 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -588,11 +588,10 @@ if (!this['read']) {
function readBinary(filename) {
var stringy = read(filename);
- var data = new Array(stringy.length+1);
+ var data = new Array(stringy.length);
for (var i = 0; i < stringy.length; i++) {
data[i] = stringy.charCodeAt(i) & 0xff;
}
- data[stringy.length] = 0;
return data;
}
diff --git a/tests/files.cpp b/tests/files.cpp
index 202c03bb..39f9e61a 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -52,7 +52,8 @@ int main()
FILE *other = fopen("test.file", "r");
assert(other);
char otherData[1000];
- fread(otherData, 1, 10, other);
+ num = fread(otherData, 1, 9, other);
+ otherData[num] = 0;
fclose(other);
printf("other=%s.\n", otherData);