[Groonga-commit] groonga/groonga at 957f75b [master] table_remove: fix a crash bug

Back to archive index

Susumu Yata null+****@clear*****
Thu Mar 24 15:21:56 JST 2016


Susumu Yata	2016-03-24 15:21:56 +0900 (Thu, 24 Mar 2016)

  New Revision: 957f75bb2d86fd78a50ab992e3a5873596f7b977
  https://github.com/groonga/groonga/commit/957f75bb2d86fd78a50ab992e3a5873596f7b977

  Message:
    table_remove: fix a crash bug
    
    GitHub: fix #504

  Modified files:
    lib/proc/proc_table.c

  Modified: lib/proc/proc_table.c (+12 -11)
===================================================================
--- lib/proc/proc_table.c    2016-03-24 15:04:52 +0900 (1cf3548)
+++ lib/proc/proc_table.c    2016-03-24 15:21:56 +0900 (3da438b)
@@ -484,6 +484,15 @@ command_table_remove(grn_ctx *ctx,
   table = grn_ctx_get(ctx,
                       GRN_TEXT_VALUE(name),
                       GRN_TEXT_LEN(name));
+  if (!table) {
+    GRN_PLUGIN_ERROR(ctx,
+                     GRN_INVALID_ARGUMENT,
+                     "[table][remove] table isn't found: <%.*s>",
+                     (int)GRN_TEXT_LEN(name),
+                     GRN_TEXT_VALUE(name));
+    grn_ctx_output_bool(ctx, GRN_FALSE);
+    return NULL;
+  }
 
   if (!grn_obj_is_table(ctx, table)) {
     const char *type_name;
@@ -499,18 +508,10 @@ command_table_remove(grn_ctx *ctx,
     return NULL;
   }
 
-  if (table) {
-    if (dependent) {
-      grn_obj_remove_dependent(ctx, table);
-    } else {
-      grn_obj_remove(ctx, table);
-    }
+  if (dependent) {
+    grn_obj_remove_dependent(ctx, table);
   } else {
-    GRN_PLUGIN_ERROR(ctx,
-                     GRN_INVALID_ARGUMENT,
-                     "[table][remove] table isn't found: <%.*s>",
-                     (int)GRN_TEXT_LEN(name),
-                     GRN_TEXT_VALUE(name));
+    grn_obj_remove(ctx, table);
   }
   grn_ctx_output_bool(ctx, !ctx->rc);
   return NULL;
-------------- next part --------------
HTML����������������������������...
Download 



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