[Groonga-commit] groonga/groonga at e62a15f [master] ii: fix a bug that grn_ii_column_update can crash

Back to archive index

Susumu Yata null+****@clear*****
Fri Feb 23 13:02:55 JST 2018


Susumu Yata	2018-02-23 13:02:55 +0900 (Fri, 23 Feb 2018)

  New Revision: e62a15f18b005b28c2586c485d5b8657e4a947ee
  https://github.com/groonga/groonga/commit/e62a15f18b005b28c2586c485d5b8657e4a947ee

  Message:
    ii: fix a bug that grn_ii_column_update can crash
    
    grn_ii_column_update crashed when oldvalue == NULL or newvalue == NULL.

  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+8 -4)
===================================================================
--- lib/ii.c    2018-02-21 12:23:06 +0900 (520bae2ef)
+++ lib/ii.c    2018-02-23 13:02:55 +0900 (0cd3a1e17)
@@ -6385,13 +6385,13 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section,
         unsigned int old_n = 0, new_n = 0;
         if (old) {
           old_n = grn_vector_size(ctx, old);
+          GRN_OBJ_INIT(&old_elem, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, old->header.domain);
         }
         if (new) {
           new_n = grn_vector_size(ctx, new);
+          GRN_OBJ_INIT(&new_elem, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, new->header.domain);
         }
         max_n = (old_n > new_n) ? old_n : new_n;
-        GRN_OBJ_INIT(&old_elem, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, old->header.domain);
-        GRN_OBJ_INIT(&new_elem, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, new->header.domain);
         for (i = 0; i < max_n; i++) {
           grn_rc rc;
           grn_obj *old_p = NULL, *new_p = NULL;
@@ -6412,8 +6412,12 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section,
             break;
           }
         }
-        GRN_OBJ_FIN(ctx, &old_elem);
-        GRN_OBJ_FIN(ctx, &new_elem);
+        if (old) {
+          GRN_OBJ_FIN(ctx, &old_elem);
+        }
+        if (new) {
+          GRN_OBJ_FIN(ctx, &new_elem);
+        }
         return ctx->rc;
       }
     }
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180223/96a3b745/attachment.htm 



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