fix(Cursor): fix a memory leak detected by valgrind

This commit is contained in:
apocelipes
2023-12-01 15:54:46 +09:00
committed by Carter Li
parent 390801aee7
commit c398dc6c07
+7 -6
View File
@@ -96,13 +96,14 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson
if (result.error.length)
{
yyjson_mut_obj_add_str(doc, module, "error", result.error.chars);
return;
yyjson_mut_obj_add_strbuf(doc, module, "error", &result.error);
}
else
{
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "theme", &result.theme);
yyjson_mut_obj_add_strbuf(doc, obj, "size", &result.size);
}
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "theme", &result.theme);
yyjson_mut_obj_add_strbuf(doc, obj, "size", &result.size);
ffStrbufDestroy(&result.error);
ffStrbufDestroy(&result.theme);