Skip to content

Commit

Permalink
Fix RV_parse_type for old HSDS
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jan 22, 2024
1 parent d8e46c9 commit 6d2f3c7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/rest_vol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ H5_rest_url_encode_path(const char *_path)
herr_t
RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_out)
{
yajl_val parse_tree = NULL, key_obj = NULL, class_obj = NULL;
yajl_val parse_tree = NULL, key_obj = NULL, class_obj = NULL, target_tree = NULL;
char *parsed_object_string;
const char *object_class_keys[] = {"class", (const char *)0};
const char *path_name = NULL;
Expand All @@ -1690,6 +1690,8 @@ RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_o
if (NULL == (parse_tree = yajl_tree_parse(HTTP_response, NULL, 0)))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "parsing JSON failed");

target_tree = parse_tree;

/* If the response contains 'h5paths',
* it may describe multiple objects. Needs to be unwrapped first. */
if (NULL != yajl_tree_get(parse_tree, h5paths_keys, yajl_t_object)) {
Expand All @@ -1702,14 +1704,11 @@ RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_o

const char *path_keys[] = {path_name, (const char *)0};

if (NULL == (key_obj = yajl_tree_get(key_obj, path_keys, yajl_t_object)))
if (NULL == (target_tree = yajl_tree_get(key_obj, path_keys, yajl_t_object)))
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "unable to parse object under path key");
}

if (key_obj->u.object.len == 0)
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "parsed h5paths object was empty");

if (NULL == (key_obj = yajl_tree_get(key_obj, object_class_keys, yajl_t_string))) {
if (NULL == (key_obj = yajl_tree_get(target_tree, object_class_keys, yajl_t_string))) {
FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "couldn't parse object class");
}

Expand Down

0 comments on commit 6d2f3c7

Please sign in to comment.