Skip to content

Commit 13be96d

Browse files
committed
[fix] fixed some bugs in stat module.
1 parent 671c353 commit 13be96d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ngx_rtmp_stat_module.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,9 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
711711
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
712712
"%D", ctx->cs[1].timestamp -
713713
ctx->cs[0].timestamp) - bbuf);
714+
} else {
715+
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
716+
"%D", 0) - bbuf);
714717
}
715718
NGX_RTMP_STAT_L("</avsync>\r\n");
716719

@@ -736,6 +739,9 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
736739
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
737740
"%D", ctx->cs[1].timestamp -
738741
ctx->cs[0].timestamp) - bbuf);
742+
} else {
743+
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
744+
"%D", 0) - bbuf);
739745
}
740746

741747
NGX_RTMP_STAT_L(",\"timestamp\":");
@@ -1276,7 +1282,7 @@ ngx_rtmp_stat_application_recorders(ngx_http_request_t *r, ngx_chain_t ***lll,
12761282
flag[len++] = ',';
12771283
}
12781284

1279-
if (NGX_RTMP_MAX_URL - len > sizeof("\"video\"")) {
1285+
if (NGX_RTMP_MAX_URL - len >= sizeof("\"video\"")) {
12801286
*ngx_snprintf(flag + ngx_strlen(flag),
12811287
NGX_RTMP_MAX_URL - len,
12821288
"%s", "\"video\"") = 0;
@@ -1296,7 +1302,7 @@ ngx_rtmp_stat_application_recorders(ngx_http_request_t *r, ngx_chain_t ***lll,
12961302
flag[len++] = ',';
12971303
}
12981304

1299-
if (NGX_RTMP_MAX_URL - len > sizeof("\"audio\"")) {
1305+
if (NGX_RTMP_MAX_URL - len >= sizeof("\"audio\"")) {
13001306
*ngx_snprintf(flag + ngx_strlen(flag),
13011307
NGX_RTMP_MAX_URL - len,
13021308
"%s", "\"audio\"") = 0;
@@ -1316,7 +1322,7 @@ ngx_rtmp_stat_application_recorders(ngx_http_request_t *r, ngx_chain_t ***lll,
13161322
flag[len++] = ',';
13171323
}
13181324

1319-
if (NGX_RTMP_MAX_URL - len > sizeof("\"keyframes\"")) {
1325+
if (NGX_RTMP_MAX_URL - len >= sizeof("\"keyframes\"")) {
13201326
*ngx_snprintf(flag + ngx_strlen(flag),
13211327
NGX_RTMP_MAX_URL - len,
13221328
"%s", "\"keyframes\"") = 0;
@@ -1336,7 +1342,7 @@ ngx_rtmp_stat_application_recorders(ngx_http_request_t *r, ngx_chain_t ***lll,
13361342
flag[len++] = ',';
13371343
}
13381344

1339-
if (NGX_RTMP_MAX_URL - len > sizeof("\"manual\"")) {
1345+
if (NGX_RTMP_MAX_URL - len >= sizeof("\"manual\"")) {
13401346
*ngx_snprintf(flag + ngx_strlen(flag),
13411347
NGX_RTMP_MAX_URL - len,
13421348
"%s", "\"manual\"") = 0;

0 commit comments

Comments
 (0)