Fix: fs.readFile would execute callbacks twice

fs.readFile was executing a callback in a try..catch context, which is
a problem in itself. To make matters worse, it would re-execute the
same callback if there was an execution.

This patch fixes both of these problems.
This commit is contained in:
Felix Geisendörfer 2010-06-03 12:37:21 +02:00 коммит произвёл Ryan Dahl
Родитель 55d7352189
Коммит 55e964ec19
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -73,10 +73,12 @@ fs.readFile = function (path, encoding_, callback) {
binding.close(fd);
if (encoding) {
try {
callback(null, buffer.toString(encoding));
var str = buffer.toString(encoding);
} catch (err) {
callback(err);
return;
}
callback(null, str);
} else {
callback(null, buffer);
}