fix crash in motif textfield functions

7 days ago

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 06 Apr 2025 13:53:33 +0200 (7 days ago)
changeset 555
0b1bb5687dca
parent 554
28e490aa15e3
child 556
1a95de56dadc

fix crash in motif textfield functions

ui/motif/text.c file | annotate | diff | comparison | revisions
--- 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);
 }
 
 

mercurial