From 9188721c6b19e1303a90ff64e6581e1b4bc87070 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 11 Nov 2009 17:49:31 +0100 Subject: [PATCH] Fix segfault on basejob code --- bacula/src/cats/sql_get.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 0bcba5b91c..340ebd039d 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -1224,14 +1224,16 @@ bool db_get_base_file_list(JCR *jcr, B_DB *mdb, bool db_get_base_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr, JobId_t *jobid) { + POOL_MEM query(PM_FNAME); + utime_t StartTime; + db_int64_ctx lctx; char date[MAX_TIME_LENGTH]; bool ret=false; - int64_t id = *jobid = 0; - POOLMEM *query = get_pool_memory(PM_FNAME); + *jobid = 0; // char clientid[50], filesetid[50]; - utime_t StartTime = (jr->StartTime)?jr->StartTime:time(NULL); + StartTime = (jr->StartTime)?jr->StartTime:time(NULL); bstrutime(date, sizeof(date), StartTime + 1); /* we can take also client name, fileset, etc... */ @@ -1251,17 +1253,16 @@ bool db_get_base_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr, JobId_t *jobid) // edit_uint64(jr->FileSetId, filesetid)); date); - Dmsg1(10, "db_get_base_jobid q=%s\n", query); - if (!db_sql_query(mdb, query, db_int64_handler, &id)) { + Dmsg1(10, "db_get_base_jobid q=%s\n", query.c_str()); + if (!db_sql_query(mdb, query.c_str(), db_int64_handler, &lctx)) { goto bail_out; } - *jobid = (JobId_t) id; + *jobid = (JobId_t) lctx.value; - Dmsg1(10, "db_get_base_jobid=%lld\n", id); + Dmsg1(10, "db_get_base_jobid=%lld\n", *jobid); ret = true; bail_out: - free_pool_memory(query); return ret; } -- 2.39.5