@@ -2760,27 +2760,26 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
2760
2760
2761
2761
const enum encoding encoding = ParseEncoding (isolate, args[1 ], UTF8);
2762
2762
2763
- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2764
- if ( req_wrap_async != nullptr ) { // mkdtemp(tmpl, encoding, req)
2763
+ if (argc > 2 ) { // mkdtemp(tmpl, encoding, req)
2764
+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2765
2765
FS_ASYNC_TRACE_BEGIN1 (
2766
2766
UV_FS_MKDTEMP, req_wrap_async, " path" , TRACE_STR_COPY (*tmpl))
2767
2767
AsyncCall (env, req_wrap_async, args, " mkdtemp" , encoding, AfterStringPath,
2768
2768
uv_fs_mkdtemp, *tmpl);
2769
- } else { // mkdtemp(tmpl, encoding, undefined, ctx)
2770
- CHECK_EQ (argc, 4 );
2771
- FSReqWrapSync req_wrap_sync;
2769
+ } else { // mkdtemp(tmpl, encoding)
2770
+ FSReqWrapSync req_wrap_sync (" mkdtemp" , *tmpl);
2772
2771
FS_SYNC_TRACE_BEGIN (mkdtemp );
2773
- SyncCall (env, args[ 3 ], &req_wrap_sync, " mkdtemp " ,
2774
- uv_fs_mkdtemp, *tmpl);
2772
+ int result =
2773
+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_mkdtemp, *tmpl);
2775
2774
FS_SYNC_TRACE_END (mkdtemp );
2776
- const char * path = req_wrap_sync.req .path ;
2777
-
2775
+ if (is_uv_error (result)) {
2776
+ return ;
2777
+ }
2778
2778
Local<Value> error;
2779
2779
MaybeLocal<Value> rc =
2780
- StringBytes::Encode (isolate, path, encoding, &error);
2780
+ StringBytes::Encode (isolate, req_wrap_sync. req . path , encoding, &error);
2781
2781
if (rc.IsEmpty ()) {
2782
- Local<Object> ctx = args[3 ].As <Object>();
2783
- ctx->Set (env->context (), env->error_string (), error).Check ();
2782
+ env->isolate ()->ThrowException (error);
2784
2783
return ;
2785
2784
}
2786
2785
args.GetReturnValue ().Set (rc.ToLocalChecked ());
0 commit comments