[Groonga-commit] groonga/groonga at 5263555 [master] Fix a memory leak when an error is occurred in grn_expr_exec()

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 1 16:43:55 JST 2015


Kouhei Sutou	2015-07-01 16:43:55 +0900 (Wed, 01 Jul 2015)

  New Revision: 5263555221833d7dd2aa78599f00e00f3a1386af
  https://github.com/groonga/groonga/commit/5263555221833d7dd2aa78599f00e00f3a1386af

  Message:
    Fix a memory leak when an error is occurred in grn_expr_exec()
    
    For example, unsupported operator (e.g. GRN_OP_TERM_EXTRACT) is used.
    "not implemented operator assigned" is occurred for the case.

  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+6 -1)
===================================================================
--- lib/expr.c    2015-07-01 16:35:29 +0900 (4f46d23)
+++ lib/expr.c    2015-07-01 16:43:55 +0900 (9481d19)
@@ -1275,7 +1275,10 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
 }
 
 #define PUSH1(v) do {\
-  if (EXPRVP(v)) { vp++; }\
+  if (EXPRVP(v)) {\
+    vp++;\
+    if (vp - e->values > e->values_tail) { e->values_tail = vp - e->values; }\
+  }\
   s1 = s0;\
   *sp++ = s0 = v;\
 } while (0)
@@ -1302,6 +1305,7 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
   } else {\
     if (sp < s_ + 1) { ERR(GRN_INVALID_ARGUMENT, "stack underflow"); goto exit; }\
     sp[-1] = s0 = value = vp++;\
+    if (vp - e->values > e->values_tail) { e->values_tail = vp - e->values; }\
     s0->header.impl_flags |= GRN_OBJ_EXPRVALUE;\
   }\
 } while (0)
@@ -1315,6 +1319,7 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
   if (sp < s_ + 1) { ERR(GRN_INVALID_ARGUMENT, "stack underflow"); goto exit; }\
   s1 = sp[-2];\
   sp[-1] = s0 = value = vp++;\
+  if (vp - e->values > e->values_tail) { e->values_tail = vp - e->values; }\
   s0->header.impl_flags |= GRN_OBJ_EXPRVALUE;\
 } while (0)
 
-------------- next part --------------
HTML����������������������������...
Download 



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