Skip to content

Commit

Permalink
Return from fr_jason_afrom_pair_list should not be const
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jan 20, 2020
1 parent b2f2d1b commit 4703ed8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/json/base.h
Expand Up @@ -68,5 +68,5 @@ size_t fr_json_from_pair(char *out, size_t outlen, VALUE_PAIR const *vp);

void fr_json_version_print(void);

const char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const char *prefix);
char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const char *prefix);
#endif
7 changes: 4 additions & 3 deletions src/lib/json/json.c
Expand Up @@ -364,12 +364,13 @@ void fr_json_version_print(void)
* @param[in] prefix The prefix to use, can be NULL to skip the prefix.
* @return JSON string representation of the value pairs
*/
const char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const char *prefix)
char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const char *prefix)
{
fr_cursor_t cursor;
VALUE_PAIR *vp;
struct json_object *obj;
const char *p;
char *out;
char buf[FR_DICT_ATTR_MAX_NAME_LEN + 32];

MEM(obj = json_object_new_object());
Expand Down Expand Up @@ -445,10 +446,10 @@ const char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const cha
}

MEM(p = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN));
MEM(p = talloc_strdup(ctx, p));
MEM(out = talloc_strdup(ctx, p));

json_object_put(obj); /* Should also free string buff from above */

return p;
return out;
}

0 comments on commit 4703ed8

Please sign in to comment.