[Groonga-commit] groonga/groonga at d8cec15 [master] pat: fix a bug that chop() may return true for no suffix case

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Oct 25 14:49:19 JST 2014


Kouhei Sutou	2014-10-25 14:49:19 +0900 (Sat, 25 Oct 2014)

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

  Message:
    pat: fix a bug that chop() may return true for no suffix case
    
    `**key` may not be NUL-terminated. So we should use `end` to detect the
    end of string.

  Modified files:
    lib/pat.c

  Modified: lib/pat.c (+3 -3)
===================================================================
--- lib/pat.c    2014-10-25 12:26:20 +0900 (5b03e61)
+++ lib/pat.c    2014-10-25 14:49:19 +0900 (25afb7e)
@@ -749,16 +749,16 @@ _grn_pat_add(grn_ctx *ctx, grn_pat *pat, const uint8_t *key, uint32_t size, uint
   return r;
 }
 
-inline static int
+inline static grn_bool
 chop(grn_ctx *ctx, grn_pat *pat, const char **key, const char *end, uint32_t *lkey)
 {
   size_t len = grn_charlen(ctx, *key, end);
   if (len) {
     *lkey += len;
     *key += len;
-    return **key;
+    return (end - *key) > 0;
   } else {
-    return 0;
+    return GRN_FALSE;
   }
 }
 
-------------- next part --------------
HTML����������������������������...
Télécharger 



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