diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 47d95fe8..32484a44 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -219,6 +219,12 @@ QList CutterCore::sdbList(QString path) return list; } +using SdbListPtr = std::unique_ptr; +static SdbListPtr makeSdbListPtr(SdbList *list) +{ + return {list, ls_free}; +} + QList CutterCore::sdbListKeys(QString path) { CORE_LOCK(); @@ -227,7 +233,7 @@ QList CutterCore::sdbListKeys(QString path) if (root) { void *vsi; ls_iter_t *iter; - SdbList *l = sdb_foreach_list(root, false); + SdbListPtr l = makeSdbListPtr(sdb_foreach_list(root, false)); ls_foreach(l, iter, vsi) { SdbKv *nsi = (SdbKv *)vsi; list << reinterpret_cast(nsi->base.key); @@ -2098,7 +2104,7 @@ QList CutterCore::getAllAnalClasses(bool sorted) { QList ret; - SdbList *l = r_anal_class_get_all(core_->anal, sorted); + SdbListPtr l = makeSdbListPtr(r_anal_class_get_all(core_->anal, sorted)); if (!l) { return ret; } @@ -2110,7 +2116,6 @@ QList CutterCore::getAllAnalClasses(bool sorted) auto kv = reinterpret_cast(entry); ret.append(QString::fromUtf8(reinterpret_cast(kv->base.key))); } - ls_free(l); return ret; }