MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / duplicateStringValue

Function duplicateStringValue

json/jsoncpp.cpp:2567–2581  ·  view source on GitHub ↗

Duplicates the specified string value. * @param value Pointer to the string to duplicate. Must be zero-terminated if * length is "unknown". * @param length Length of the value. if equals to unknown, then it will be * computed using strlen(value). * @return Pointer on the duplicate instance of string. */

Source from the content-addressed store, hash-verified

2565 * @return Pointer on the duplicate instance of string.
2566 */
2567static inline char* duplicateStringValue(const char* value, size_t length) {
2568 // Avoid an integer overflow in the call to malloc below by limiting length
2569 // to a sane value.
2570 if (length >= static_cast<size_t>(Value::maxInt))
2571 length = Value::maxInt - 1;
2572
2573 char* newString = static_cast<char*>(malloc(length + 1));
2574 if (newString == NULL) {
2575 throwRuntimeError("in Json::Value::duplicateStringValue(): "
2576 "Failed to allocate string value buffer");
2577 }
2578 memcpy(newString, value, length);
2579 newString[length] = 0;
2580 return newString;
2581}
2582
2583/* Record the length as a prefix.
2584 */

Callers 2

setCommentMethod · 0.85
CZStringMethod · 0.85

Calls 1

throwRuntimeErrorFunction · 0.85

Tested by

no test coverage detected