Skip to content

Commit

Permalink
Fix directive EOF error.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 15, 2023
1 parent e94861a commit 5c638a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ srs_error_t SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveCo
srs_error_t err = srs_success;

// Ignore empty config file.
if (buffer->empty()) return err;
if (ctx == SrsDirectiveContextFile && buffer->empty()) return err;

while (true) {
std::vector<string> args;
Expand Down
28 changes: 24 additions & 4 deletions trunk/src/utest/srs_utest_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,30 @@ VOID TEST(ConfigDirectiveTest, ParseInvalidNoEndOfDirective)
VOID TEST(ConfigDirectiveTest, ParseInvalidNoEndOfSubDirective)
{
srs_error_t err;

MockSrsConfigBuffer buf("dir0 {");
SrsConfDirective conf;
HELPER_ASSERT_FAILED(conf.parse(&buf));

if (true) {
MockSrsConfigBuffer buf("");
SrsConfDirective conf;
HELPER_ASSERT_SUCCESS(conf.parse(&buf));
}

if (true) {
MockSrsConfigBuffer buf("# OK");
SrsConfDirective conf;
HELPER_ASSERT_SUCCESS(conf.parse(&buf));
}

if (true) {
MockSrsConfigBuffer buf("dir0 {");
SrsConfDirective conf;
HELPER_ASSERT_FAILED(conf.parse(&buf));
}

if (true) {
MockSrsConfigBuffer buf("dir0 {} dir1 {");
SrsConfDirective conf;
HELPER_ASSERT_FAILED(conf.parse(&buf));
}
}

VOID TEST(ConfigDirectiveTest, ParseInvalidNoStartOfSubDirective)
Expand Down

0 comments on commit 5c638a4

Please sign in to comment.