Skip to content

Commit

Permalink
More fixes to JSON string buffer sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 22, 2024
1 parent 7af42c0 commit 9823460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/xjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,30 +1097,30 @@ static int GetArrayStringSize(int prefixSize, char *ptr, XType type, int ndim, c

switch(type) {
case X_UNKNOWN:
return prefixSize + sizeof(JSON_NULL);
return sizeof(JSON_NULL);

case X_STRUCT:
m = GetObjectStringSize(prefixSize, (XStructure *) ptr);
m = GetObjectStringSize(prefixSize + ilen, (XStructure *) ptr);
prop_error(fn, m);
return m;

case X_STRING:
case X_RAW:
m = GetJsonStringSize(*(char **) ptr, TERMINATED_STRING);
prop_error(fn, m);
return m + prefixSize;
return m;

case X_FIELD: {
const XField *f = (XField *) ptr;
m = GetFieldStringSize(prefixSize, f, TRUE);
m = GetFieldStringSize(prefixSize + ilen, f, TRUE);
prop_error(fn, m);
return m;
}

default:
m = xStringElementSizeOf(type);
prop_error(fn, m);
return m + prefixSize;
return m;
}
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/xstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,9 +1007,9 @@ int xReduceField(XField *f) {
}

/**
* Recursively eliminates unneccessary embedding of singular structures inside a structure as well as reduces the
* dimension of all array fields with xReduceDims(). It will also eliminate the unnecessary wrapping of a singular
* array into a single XField.
* Recursively eliminates unneccessary embedding of singular structures inside a structure and reduces the
* dimensions of array fields with xReduceDims(), recursively. It will also eliminate the unnecessary wrapping
* of a singular array into a single XField.
*
* @param s Pointer to a structure.
* @return X_SUCCESS (0) if successful or else X_STRUCT_INVALID if the argument is NULL (errno is
Expand Down

0 comments on commit 9823460

Please sign in to comment.