Skip to content

Commit

Permalink
check env null
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 committed Jul 31, 2024
1 parent 0a98aa0 commit 6398563
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/aws/common/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct aws_string;
AWS_EXTERN_C_BEGIN

/*
* Get the value of an environment variable. If the variable is not set, the output string will be set to NULL.
* Get the value of an environment variable. If the variable is not set or is empty, the output string will be set to NULL.
* Not thread-safe
*/
AWS_COMMON_API
Expand Down
2 changes: 1 addition & 1 deletion source/posix/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int aws_get_environment_value(
struct aws_string **value_out) {

const char *value = getenv(aws_string_c_str(variable_name));
if (value == NULL) {
if (value == NULL || value[0]=='\0') {
*value_out = NULL;
return AWS_OP_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion source/windows/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int aws_get_environment_value(
# pragma warning(pop)
#endif

if (value == NULL) {
if (value == NULL || value[0] == '\0') {
*value_out = NULL;
return AWS_OP_SUCCESS;
}
Expand Down

0 comments on commit 6398563

Please sign in to comment.