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

This commit is contained in:
apocelipes authored and Carter Li committed 2023-12-01 15:49:48 +08:00
1 parent 390801aee7
commit c398dc6c07
1 file changed
+7 -6
+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);