Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Fix fread() usage in WebWorkerThreads.cc to match jslib.cc's.

  Also restore the fread() size check.
  • Loading branch information...
commit 2977888582d6116b754b851e1e0a5843cd42e050 1 parent 6f17f9a
@audreyt authored
View
6 CHANGES.md
@@ -1,3 +1,9 @@
+## 0.4.5
+
+### Bug Fixes
+
+* new Worker("filename.js") was broken on OS X. (@dfellis)
+
## 0.4.3
### Bug Fixes
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "webworker-threads",
- "version": "0.4.4",
+ "version": "0.4.5",
"main": "build/Release/WebWorkerThreads.node",
"description": "Lightweight Web Worker API implementation with native threads",
"keywords": [
View
2  package.ls
@@ -1,6 +1,6 @@
#!/usr/bin/env lsc -cj
name: 'webworker-threads'
-version: '0.4.4'
+version: '0.4.5'
main: 'build/Release/WebWorkerThreads.node'
description: 'Lightweight Web Worker API implementation with native threads'
keywords: [ 'threads' 'web worker' 'a gogo' ]
View
5 src/WebWorkerThreads.cc
@@ -645,11 +645,12 @@ static char* readFile (Handle<String> path) {
fseek(fp, 0, SEEK_END);
size_t len= ftell(fp);
rewind(fp); //fseek(fp, 0, SEEK_SET);
- char *buf= (char*) calloc(len + 1, sizeof(char)); // +1 to get null terminated string
- if (fread(buf, len, 1, fp) < len) {
+ char *buf= (char*)malloc((len+1) * sizeof(char)); // +1 to get null terminated string
+ if (fread(buf, sizeof(char), len, fp) < len) {
fprintf(stderr, "Error reading the file %s\n", *c_str);
return NULL;
}
+ buf[len] = 0;
fclose(fp);
/*
printf("SOURCE:\n%s\n", buf);
View
3  src/jslib.cc
@@ -84,14 +84,11 @@ static Handle<Value> readFileSync_(const Arguments &args) {
char *buf = (char*)malloc((s+1)*sizeof(char));
size_t r = fread(buf, sizeof(char), s, f);
if (r < s) {
- // Not doing anything for now
- /*
char str[256];
sprintf(str, "Error: readfile read failed. %d %s\n", ferror(f), strerror(ferror(f)));
delete[] buf;
fclose(f);
ThrowException(Exception::Error(String::New(str)));
- */
}
buf[s] = 0;
Handle<String> str = String::New(buf);
View
2  test.ls
@@ -8,7 +8,7 @@ w = new Worker ->
for i from 2 to Math.sqrt n
continue search unless n % i
postMessage { result: n }
- postMessage {+done}
+ postMessage {+done}
w.onmessage = (data: {done, result}) ->
return setTimeout((~> @terminate!), 100ms) if done
console.log "#result is a prime"
Please sign in to comment.
Something went wrong with that request. Please try again.