diff --git a/src/node.cc b/src/node.cc index 1067dee74c8877..7f84c6be74377d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1154,13 +1154,14 @@ int LoadSnapshotDataAndRun(const SnapshotData** snapshot_data_ptr, return exit_code; } std::unique_ptr read_data = std::make_unique(); - if (!SnapshotData::FromBlob(read_data.get(), fp)) { + bool ok = SnapshotData::FromBlob(read_data.get(), fp); + fclose(fp); + if (!ok) { // If we fail to read the customized snapshot, simply exit with 1. exit_code = 1; return exit_code; } *snapshot_data_ptr = read_data.release(); - fclose(fp); } else if (per_process::cli_options->node_snapshot) { // If --snapshot-blob is not specified, we are reading the embedded // snapshot, but we will skip it if --no-node-snapshot is specified.