Skip to content

Commit

Permalink
add null ptr check.
Browse files Browse the repository at this point in the history
  • Loading branch information
huiguangjun committed Sep 13, 2024
1 parent 4526fee commit bbc0c91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions oss_c_sdk/oss_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ static void generate_rtmp_proto(const oss_request_options_t *options,

int is_valid_ip(const char *str)
{
if (!str) {
return 0;
}

if (INADDR_NONE == inet_addr(str) || INADDR_ANY == inet_addr(str)) {
return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions oss_c_sdk_test/test_aos.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ void test_is_valid_ip(CuTest *tc) {
ret = is_valid_ip("0.0.0.0");
CuAssertIntEquals(tc, 0, ret);

ret = is_valid_ip(NULL);
CuAssertIntEquals(tc, 0, ret);

ret = is_valid_ip("");
CuAssertIntEquals(tc, 0, ret);

printf("test_is_valid_ip ok\n");
}

Expand Down

0 comments on commit bbc0c91

Please sign in to comment.