# HG changeset patch
# User Olaf Wintermann <olaf.wintermann@gmail.com>
# Date 1743940413 -7200
# Node ID 0b1bb5687dca1410084412874b0b8b08754f0e61
# Parent  28e490aa15e3462f4b1fec7c627a63add16ae3a6
fix crash in motif textfield functions

diff -r 28e490aa15e3 -r 0b1bb5687dca ui/motif/text.c
--- a/ui/motif/text.c	Sun Apr 06 13:45:18 2025 +0200
+++ b/ui/motif/text.c	Sun Apr 06 13:53:33 2025 +0200
@@ -433,7 +433,9 @@
 }
 
 char* ui_textfield_get(UiString *str) {
-    str->value.free(str->value.ptr);
+    if(str->value.free) {
+        str->value.free(str->value.ptr);
+    }
     char *value = XmTextFieldGetString(str->obj);
     str->value.ptr = value;
     str->value.free = (ui_freefunc)XtFree;
@@ -442,8 +444,10 @@
 
 void ui_textfield_set(UiString *str, const char *value) {
     XmTextFieldSetString(str->obj, (void*)value);
+    if(str->value.free) {
+        str->value.free(str->value.ptr);
+    }
     str->value.ptr = NULL;
-    str->value.free(str->value.ptr);
 }