rsyslog / rsyslog/libfastjson

Found a problem when using the same object in different objects

Open
#165 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
61
Forks
35
Avg merge
21m
Merged PRs (30d)
2

Description

Found a problem when using the same object in different objects

fjson_object *m = fjson_object_new_object();

    fjson_object *i = fjson_object_new_int(1);

    fjson_object *a = fjson_object_new_object();
    fjson_object_object_add(a, "i", i);

    fjson_object *b = fjson_object_new_object();
    fjson_object_object_add(b, "i", i);

    fjson_object_object_add(m, "a", a);
    fjson_object_object_add(m, "b", b);

    printf("%s\n", fjson_object_to_json_string_ext(m, FJSON_TO_STRING_PLAIN));
    fjson_object_put(m); // segmentation fault due to trying to delete one i in different objects

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided example, then inspect fjson_object_object_add and fjson_object_put to understand how shared objects are handled. Done means the example no longer segfaults when the same object is added to both a and b and m is released.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.