From 30b731de54845a7131937d83014361bb01ff7d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=D1=91m=20Mishin?= Date: Mon, 20 Apr 2026 11:26:13 +0300 Subject: [PATCH] fix: make Jni::FreeTrueUtf8 const-safe TextEditor/TextEditorLanguageDefinition use 'const char* value = env->GetStringUTFChars(...)' then release via the same pointer. After the mass replace the release side called FreeTrueUtf8(char*) with a const char* argument, which fails to compile. Switch the helper signature to take const char* so both const and non-const call sites build. --- imgui-binding/src/main/native/jni_common.cpp | 4 ++-- imgui-binding/src/main/native/jni_common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imgui-binding/src/main/native/jni_common.cpp b/imgui-binding/src/main/native/jni_common.cpp index 3fc5a90..77ad2da 100644 --- a/imgui-binding/src/main/native/jni_common.cpp +++ b/imgui-binding/src/main/native/jni_common.cpp @@ -161,7 +161,7 @@ namespace Jni return buf; } - void FreeTrueUtf8(char* p) { - if (p != nullptr) free(p); + void FreeTrueUtf8(const char* p) { + if (p != nullptr) free((void*)p); } } diff --git a/imgui-binding/src/main/native/jni_common.h b/imgui-binding/src/main/native/jni_common.h index 85bde37..e97128c 100644 --- a/imgui-binding/src/main/native/jni_common.h +++ b/imgui-binding/src/main/native/jni_common.h @@ -54,5 +54,5 @@ namespace Jni // the glyph atlas even when the glyph is registered. Caller must release with // FreeTrueUtf8(). Returns nullptr iff the input jstring is null. char* ToTrueUtf8(JNIEnv* env, jstring s); - void FreeTrueUtf8(char* p); + void FreeTrueUtf8(const char* p); }