Skip to content

Commit

Permalink
fix(Cursor): fix a memory leak detected by valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
apocelipes committed Dec 1, 2023
1 parent 390801a commit 6bbbbb1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/modules/cursor/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6bbbbb1

Please sign in to comment.