瀏覽代碼

llama-bench : fix NUL terminators in CPU name (#9313)

slaren 1 年之前
父節點
當前提交
bdf314f38a
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      examples/llama-bench/llama-bench.cpp

+ 3 - 0
examples/llama-bench/llama-bench.cpp

@@ -124,6 +124,9 @@ static std::string get_cpu_info() {
                         (LPBYTE)cpu_brand,
                         (LPBYTE)cpu_brand,
                         &cpu_brand_size) == ERROR_SUCCESS) {
                         &cpu_brand_size) == ERROR_SUCCESS) {
         id.assign(cpu_brand, cpu_brand_size);
         id.assign(cpu_brand, cpu_brand_size);
+        if (id.find('\0') != std::string::npos) {
+            id.resize(id.find('\0'));
+        }
     }
     }
     RegCloseKey(hKey);
     RegCloseKey(hKey);
 #endif
 #endif