[Groonga-commit] groonga/groonga [master] fix a memory leak.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 7月 15日 (木) 14:04:54 JST


Kouhei Sutou	2010-07-15 05:04:54 +0000 (Thu, 15 Jul 2010)

  New Revision: 70e2a9989342d5a5f1e14d35a03e6d8c313f78e4

  Log:
    fix a memory leak.

  Modified files:
    lib/output.c

  Modified: lib/output.c (+4 -2)
===================================================================
--- lib/output.c    2010-07-15 00:35:12 +0000 (2197fd7)
+++ lib/output.c    2010-07-15 05:04:54 +0000 (aaab31d)
@@ -810,12 +810,13 @@ grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
                *ve = (grn_id *)GRN_BULK_CURR(obj);
         grn_output_array_open(ctx, outbuf, output_type, "VECTOR", -1);
         if (v < ve) {
+          grn_obj key;
+          GRN_OBJ_INIT(&key, GRN_BULK, 0, range->header.domain);
           for (;;) {
-            grn_obj key;
             if (range->header.type != GRN_TABLE_NO_KEY) {
-              GRN_OBJ_INIT(&key, GRN_BULK, 0, range->header.domain);
               grn_table_get_key2(ctx, range, *v, &key);
               grn_output_obj(ctx, outbuf, output_type, &key, NULL);
+              GRN_BULK_REWIND(&key);
             } else {
               grn_text_lltoa(ctx, outbuf, *v);
             }
@@ -826,6 +827,7 @@ grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
               break;
             }
           }
+          GRN_OBJ_FIN(ctx, &key);
         }
         grn_output_array_close(ctx, outbuf, output_type);
       }




Groonga-commit メーリングリストの案内
Back to archive index