From d46e52e07f1a3a1581063995cdb39a7abe297d71 Mon Sep 17 00:00:00 2001 From: WolframRhodium Date: Sun, 26 May 2024 13:51:10 +0800 Subject: [PATCH] vstrt/vs_tensorrt.cpp: cosmetics --- vstrt/vs_tensorrt.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vstrt/vs_tensorrt.cpp b/vstrt/vs_tensorrt.cpp index 15be7d8..c2df424 100644 --- a/vstrt/vs_tensorrt.cpp +++ b/vstrt/vs_tensorrt.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -420,12 +421,17 @@ static void VS_CC vsTrtCreate( return set_error("open engine failed"); } - size_t engine_nbytes = engine_stream.tellg(); + auto engine_nbytes = engine_stream.tellg(); + + if (engine_nbytes == -1) { + return set_error("open engine failed"); + } + std::unique_ptr engine_data { - (char *) malloc(engine_nbytes), free + (char *) malloc(static_cast(engine_nbytes)), free }; engine_stream.seekg(0, std::ios::beg); - engine_stream.read(engine_data.get(), engine_nbytes); + engine_stream.read(engine_data.get(), static_cast(engine_nbytes)); d->runtime.reset(nvinfer1::createInferRuntime(d->logger)); auto maybe_engine = initEngine(engine_data.get(), engine_nbytes, d->runtime, !d->flexible_output_prop.empty());