Instead of not appending an option to the option list if JSON output is
disabled, only skip appending an option to the JSON option list. See also
commit
b127b679769c ("client: fix segfault for !json output").
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
{
struct cmd_job_option *pdu = (struct cmd_job_option *) cmd->payload;
{
struct cmd_job_option *pdu = (struct cmd_job_option *) cmd->payload;
- if (!job_opt_object)
- return;
-
pdu->global = le16_to_cpu(pdu->global);
pdu->truncated = le16_to_cpu(pdu->truncated);
pdu->groupid = le32_to_cpu(pdu->groupid);
if (pdu->global) {
pdu->global = le16_to_cpu(pdu->global);
pdu->truncated = le16_to_cpu(pdu->truncated);
pdu->groupid = le32_to_cpu(pdu->groupid);
if (pdu->global) {
+ if (!job_opt_object)
+ return;
+
json_object_add_value_string(job_opt_object,
(const char *)pdu->name,
(const char *)pdu->value);
json_object_add_value_string(job_opt_object,
(const char *)pdu->name,
(const char *)pdu->value);