From 76526caa3568fe94126a30b4c48b490169c24ee1 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Wed, 25 Jun 2014 13:51:07 -0400 Subject: [PATCH] Add a clarifying comment about not coercing buffers passed to read operations. --- src/filesystem/implementation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index 8010a68..4744428 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -60,6 +60,12 @@ function standard_check_result_cb(callback) { * Coerce array-like data to Buffer so we can .copy(), etc. * Allow null, a Buffer, or an object that can be dealt with * by the Buffer constructor (e.g., Typed Array, Array, ...) + * + * WARNING: be very careful not to call this on parameters of + * API methods that pass storage (like read). You don't want to + * overwrite a buffer that a caller is holding a reference to, + * and expects to be filled via the read. If the caller passes + * in a non-Buffer, we should throw instead of coerce. */ function ensureBuffer(maybeBuffer) { if(!maybeBuffer) {