From 5df535fdf26e716548aa25b96e952d21c514dd67 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 23 May 2024 14:26:19 +0800 Subject: [PATCH] Fix dangling pointer error --- sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h index 3c96f03bc..3bcaf390b 100644 --- a/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h +++ b/sherpa-onnx/csrc/offline-recognizer-paraformer-impl.h @@ -59,9 +59,9 @@ static OfflineRecognitionResult Convert( mergeable = false; if (i > 0) { - const uint8_t *p = reinterpret_cast( - sym_table[src.tokens[i - 1]].c_str()); - if (p[0] < 0x80) { + const uint8_t p = reinterpret_cast( + sym_table[src.tokens[i - 1]].c_str())[0]; + if (p < 0x80) { // put a space between ascii and non-ascii text.append(" "); }