Skip to content

Commit

Permalink
RefCounted: Resolved a GCC warning
Browse files Browse the repository at this point in the history
Don't ignore the return value (i.e. failure) of asprintf.
  • Loading branch information
snej committed Jan 16, 2025
1 parent 3a88074 commit 6601272
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Fleece/Support/RefCounted.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ namespace fleece {
__cold static void fail(const RefCounted *obj, const char *what, int refCount,
bool andThrow =true)
{
char *message;
asprintf(&message,
char *message = nullptr;
int n = asprintf(&message,
"RefCounted object <%s @ %p> %s while it had an invalid refCount of %d (0x%x)",
Unmangle(typeid(*obj)).c_str(), obj, what, refCount, refCount);
if (n < 0)
throw std::runtime_error("RefCounted object has an invalid refCount");
#ifdef WarnError
WarnError("%s", message);
#else
Expand Down

0 comments on commit 6601272

Please sign in to comment.