Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault while executing conf get in JSON format #399

Closed
fluca1978 opened this issue Feb 16, 2024 · 0 comments · Fixed by #400
Closed

Segmentation fault while executing conf get in JSON format #399

fluca1978 opened this issue Feb 16, 2024 · 0 comments · Fixed by #400
Labels
bug Something isn't working

Comments

@fluca1978
Copy link
Collaborator

pgagroal version 4d14643, when doing conf get in JSON format there is a segfault:

% pgagroal-cli conf -F json set log_level debug
{
        "command":      {
                "name": "conf set",
                "status":       "OK",
                "error":        0,
                "exit-status":  0,
                "output":       {
                        "key":  "log_level",
                        "value":        "debug",
                        "expected":     "debug"
                }
        },
        "application":  {
                "name": "pgagroal-cli",
                "major":        1,
                "minor":        6,
                "patch":        0,
                "version":      "1.6.0"
        }
}

`zsh:` segmentation fault  pgagroal-cli conf -F json set log_level debug

The other JSON commands seems to be find.

@fluca1978 fluca1978 added the bug Something isn't working label Feb 16, 2024
fluca1978 added a commit to fluca1978/pgagroal that referenced this issue Feb 16, 2024
The `conf get` implementation in JSON format was trying to extract the
command status after having freed the JSON object.
This commit changes the `pgagroal_json_print_and_free_json_object()`
function making it returning the status code for the command
contained (possibly) in the JSON object.
In this way, it is possible to call the fuction in a way like:

     int status = pgagroal_json_print_and_free_json_object( json );

and get back the status leaving the function to free the object.

Close agroal#399
@jesperpedersen jesperpedersen changed the title Swgmentation fault while executing conf get in JSON format Segmentation fault while executing conf get in JSON format Feb 16, 2024
fluca1978 added a commit to fluca1978/pgagroal that referenced this issue Feb 16, 2024
The `conf get` implementation in JSON format was trying to extract the
command status after having freed the JSON object.
This commit changes the `pgagroal_json_print_and_free_json_object()`
function making it returning the status code for the command
contained (possibly) in the JSON object.
In this way, it is possible to call the fuction in a way like:

     int status = pgagroal_json_print_and_free_json_object( json );

and get back the status leaving the function to free the object.

Fixes also a memory leak in the `conf get` command: the JSON object
was not destroyed at the end.

Close agroal#399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant