Skip to content

Conversation

@Alanscut
Copy link
Collaborator

@Alanscut Alanscut commented Mar 24, 2020

Changes

cJSON.c Outdated
return NULL;
}
memcpy(copy, valuestring, length);
if (!(object->type & cJSON_IsReference) && (object->valuestring != NULL))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated check in a single thread

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks your reminder!

cJSON.c Outdated
{
return NULL;
}
length = strlen(valuestring) + sizeof("");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the new str length does not exceed the current value, whether to re-allocate memory

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good suggestion, In this case, we don't need to allocate memory, just re-assign the valuestring

@Alanscut Alanscut force-pushed the 20200324 branch 2 times, most recently from f7bd395 to b9eb61c Compare March 25, 2020 07:33
@Alanscut Alanscut changed the title add new function of cJSON_SetValuestringToObject add new function of cJSON_SetValuestring Mar 26, 2020
@Alanscut Alanscut merged commit f12cd7b into DaveGamble:master Apr 2, 2020
@Alanscut Alanscut deleted the 20200324 branch October 22, 2021 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants