bare-fs 4.7.2 → 4.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.c CHANGED
@@ -74,15 +74,19 @@ bare_fs__request_destroy(bare_fs_req_t *req) {
74
74
 
75
75
  static void
76
76
  bare_fs__on_request_teardown(js_deferred_teardown_t *handle, void *data) {
77
- int err;
78
-
79
77
  bare_fs_req_t *req = (bare_fs_req_t *) data;
80
78
 
81
79
  req->exiting = true;
82
80
 
81
+ // If a request is still in flight its result callback is guaranteed to run,
82
+ // even when the underlying work is cancelled successfully, in which case it
83
+ // completes with `UV_ECANCELED`. Destroying the request here would leave that
84
+ // pending callback to operate on freed memory, so we only attempt to cancel
85
+ // the work to hurry it along and defer destruction to the result callback.
83
86
  if (req->inflight) {
84
- err = uv_cancel((uv_req_t *) &req->handle);
85
- if (err < 0) return;
87
+ uv_cancel((uv_req_t *) &req->handle);
88
+
89
+ return;
86
90
  }
87
91
 
88
92
  bare_fs__request_destroy(req);
@@ -374,7 +378,7 @@ bare_fs_request_result_string(js_env_t *env, js_callback_info_t *info) {
374
378
  err = js_create_arraybuffer(env, len, (void *) &data, &result);
375
379
  assert(err == 0);
376
380
 
377
- strncpy(data, req->handle.ptr, len);
381
+ memcpy(data, req->handle.ptr, len);
378
382
 
379
383
  return result;
380
384
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "4.7.2",
3
+ "version": "4.7.3",
4
4
  "description": "Native file system operations for Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file