mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix the snprintf size issue.
This commit is contained in:
parent
1ab584b2ae
commit
a71eddd56a
10 changed files with 46 additions and 17 deletions
|
@ -276,16 +276,16 @@ bool srs_check_ip_addr_valid(string ip)
|
|||
string srs_int2str(int64_t value)
|
||||
{
|
||||
// len(max int64_t) is 20, plus one "+-."
|
||||
char tmp[22];
|
||||
snprintf(tmp, 22, "%" PRId64, value);
|
||||
char tmp[21 + 1];
|
||||
snprintf(tmp, sizeof(tmp), "%" PRId64, value);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
string srs_float2str(double value)
|
||||
{
|
||||
// len(max int64_t) is 20, plus one "+-."
|
||||
char tmp[22];
|
||||
snprintf(tmp, 22, "%.2f", value);
|
||||
char tmp[21 + 1];
|
||||
snprintf(tmp, sizeof(tmp), "%.2f", value);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue