Details
Description
This is found while using Swift Todo that is implemented by using CBL-C during the test fest.
Here is the line that has the problem:
The result FLStringResult has size = 29 instead of 24. As a result, a wrong date-time string is written into the database.
Here is an example :
"createdAt": "2023-04-26T00:56:23.563Z\u0004\t(\u0001", |
Note: The same issue doesn't happen when using the same call in CBL iOS's Objective-C Tests.
Analysis:
https://github.com/couchbase/fleece/blob/release/3.1/Fleece/API_Impl/Fleece.cc#L57
1. From the code linked above, the strlen() function could return a wrong size.
2. FormatISO8601Date() already returns the slice object with the correct size, the fix could be just creating the FLStringResult result with the returned slice object as follows
FLStringResult FLTimestamp_ToString(FLTimestamp timestamp, bool asUTC) FLAPI {
|
char str[kFormattedISO8601DateMaxSize]; |
slice s = FormatISO8601Date(str, timestamp, asUTC);
|
return FLSlice_Copy(s); |
}
|