QA corner: better fix of leaked ulm.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sat, 9 Feb 2013 23:07:37 +0000 (00:07 +0100)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 14 Feb 2013 14:37:12 +0000 (15:37 +0100)
org.glite.lb.server/src/store.c.T

index 23eb558..789706a 100644 (file)
@@ -451,11 +451,14 @@ static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,char
 #endif
 
        char    *stmt;
-       int     err = 0;
+       int     err = 0, local_ulm = 0;
 
        assert(ulm || e);
        edg_wll_ResetError(ctx);
-       if (!ulm) ulm = edg_wll_UnparseEvent(ctx, e);
+       if (!ulm) {
+               ulm = edg_wll_UnparseEvent(ctx, e);
+               local_ulm = 1;
+       }
        if (!ulm) return edg_wll_Error(ctx, NULL, NULL);
 
 #ifndef LB_EVENTS_BLOB
@@ -527,7 +530,6 @@ static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,char
                free(stmt);
        }
 #else
-       if (!ulm) ulm = edg_wll_UnparseEvent(ctx, e);
        trio_asprintf(&stmt, "insert into events_flesh (jobid, event, ulm) values ('%|Ss', %d, '%|Ss')", jobid, no, ulm);
        glite_common_log_msg(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
@@ -535,6 +537,8 @@ static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,char
        free(stmt);
 #endif
 
+       if (local_ulm) free(ulm);
+
        return err;
 }