Revision: 6454
Author: deton.kih
Date: Fri Jun 18 19:08:34 2010
Log: * gtk/uim-cand-win-tbl-gtk.c
  - (init_labelchar_table): Add uim_scm_strp() check before uim_scm_c_str()
* helper/candwin-tbl-gtk.c
  - (init_labelchar_table): Add commented out uim_scm_strp() check
for investigation (instead of ignoreing silently in uim-cand-win-tbl-gtk.c)

http://code.google.com/p/uim/source/detail?r=6454

Modified:
 /trunk/gtk/uim-cand-win-tbl-gtk.c
 /trunk/helper/candwin-tbl-gtk.c

=======================================
--- /trunk/gtk/uim-cand-win-tbl-gtk.c   Fri Jun 18 00:58:28 2010
+++ /trunk/gtk/uim-cand-win-tbl-gtk.c   Fri Jun 18 19:08:34 2010
@@ -232,19 +232,24 @@
     }
     return default_labelchar_table;
   }
-  table = (gchar *)g_malloc(LABELCHAR_NR_CELLS);
+  table = (gchar *)g_malloc0(LABELCHAR_NR_CELLS);
   if (table == NULL) {
     free(ary0);
     return default_labelchar_table;
   }
-  for (i = 0; i < LABELCHAR_NR_CELLS; i++, ary++) {
-    table[i] = '\0';
-    if (i < len) {
-      char *str = uim_scm_c_str(*ary);
-      if (str) {
-        table[i] = *str;
-        free(str);
-      }
+  for (i = 0; i < len && i < LABELCHAR_NR_CELLS; i++, ary++) {
+    char *str;
+    if (!uim_scm_strp(*ary)) {
+      /* XXX: output notify message? */
+      g_free(table);
+      free(ary0);
+      return default_labelchar_table;
+    }
+    str = uim_scm_c_str(*ary);
+    if (str) {
+      /* XXX: only use first char */
+      table[i] = *str;
+      free(str);
     }
   }
   free(ary0);
=======================================
--- /trunk/helper/candwin-tbl-gtk.c     Fri Jun 18 00:58:28 2010
+++ /trunk/helper/candwin-tbl-gtk.c     Fri Jun 18 19:08:34 2010
@@ -439,19 +439,28 @@
     }
     return default_labelchar_table;
   }
-  table = (gchar *)g_malloc(LABELCHAR_NR_CELLS);
+  table = (gchar *)g_malloc0(LABELCHAR_NR_CELLS);
   if (table == NULL) {
     free(ary0);
     return default_labelchar_table;
   }
-  for (i = 0; i < LABELCHAR_NR_CELLS; i++, ary++) {
-    table[i] = '\0';
-    if (i < len) {
-      char *str = uim_scm_c_str(*ary);
-      if (str) {
-        table[i] = *str;
-        free(str);
-      }
+  for (i = 0; i < len && i < LABELCHAR_NR_CELLS; i++, ary++) {
+    char *str;
+#if 0 /* 0 for investigation (Because uim-candwin-tbl-gtk is standalone,
+         bad effects to other programs are smaller than gtk-immodule)
+       */
+    if (!uim_scm_strp(*ary)) {
+      /* XXX: output notify message? */
+      g_free(table);
+      free(ary0);
+      return default_labelchar_table;
+    }
+#endif
+    str = uim_scm_c_str(*ary);
+    if (str) {
+      /* XXX: only use first char */
+      table[i] = *str;
+      free(str);
     }
   }
   free(ary0);

Reply via email to