Skip to content

Commit d5f64f6

Browse files
committed
To avoid overflowed constant(INTEGER_OVERFLOW) occurrence, minus operation is performed only when the value is greater than 0
1 parent e402b96 commit d5f64f6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/dnssd/TxtFields.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ constexpr size_t MaxKeyLen(TxtKeyUse use)
130130
}
131131
}
132132
// minus 1 because sizeof includes the null terminator.
133-
return max - 1;
133+
return max > 0 ? max - 1 : 0;
134134
}
135135
constexpr size_t TotalKeyLen(TxtKeyUse use)
136136
{
@@ -156,7 +156,7 @@ constexpr size_t MaxValueLen(TxtKeyUse use)
156156
}
157157
}
158158
// minus 1 because sizeof includes the null terminator.
159-
return max - 1;
159+
return max > 0 ? max - 1 : 0;
160160
}
161161
constexpr size_t TotalValueLen(TxtKeyUse use)
162162
{

0 commit comments

Comments
 (0)