[Groonga-commit] groonga/groonga at 78bfff0 [master] recover: fix object name comparision

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Apr 22 10:12:44 JST 2016


Kouhei Sutou	2016-04-22 10:12:44 +0900 (Fri, 22 Apr 2016)

  New Revision: 78bfff0eaeec56ab8121ca0432f6d5f82bc03b97
  https://github.com/groonga/groonga/commit/78bfff0eaeec56ab8121ca0432f6d5f82bc03b97

  Message:
    recover: fix object name comparision

  Modified files:
    lib/db.c

  Modified: lib/db.c (+11 -4)
===================================================================
--- lib/db.c    2016-04-21 23:49:50 +0900 (3868599)
+++ lib/db.c    2016-04-22 10:12:44 +0900 (4ce0ff2)
@@ -13911,21 +13911,28 @@ grn_db_recover_index_column(grn_ctx *ctx, grn_obj *index_column)
 static grn_bool
 grn_db_recover_is_builtin(grn_ctx *ctx, grn_id id, grn_table_cursor *cursor)
 {
-  char name[GRN_TABLE_MAX_KEY_SIZE];
+  void *key;
+  const char *name;
   int name_size;
 
   if (id < GRN_N_RESERVED_TYPES) {
     return GRN_TRUE;
   }
 
-  name_size = grn_table_cursor_get_key(ctx, cursor, (void **)&name);
-  name[name_size] = '\0';
-  if (strcmp(name, "inspect") == 0) {
+  name_size = grn_table_cursor_get_key(ctx, cursor, &key);
+  name = key;
+
+#define NAME_EQUAL(value)                       \
+  (name_size == strlen(value) && memcmp(name, value, strlen(value)) == 0)
+
+  if (NAME_EQUAL("inspect")) {
     /* Just for compatibility. It's needed for users who used
        Groonga master at between 2016-02-03 and 2016-02-26. */
     return GRN_TRUE;
   }
 
+#undef NAME_EQUAL
+
   return GRN_FALSE;
 }
 
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index