Skip to content

Commit

Permalink
Fix an error check in utils (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
rumtid authored Oct 16, 2022
1 parent 16bde19 commit e219727
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/utils-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ char *b64encode(const char *input)
{
char buf[32767] = {0};
DWORD retlen = 32767;
CryptBinaryToString((BYTE*) input, strlen(input), CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, buf, &retlen);
if (!CryptBinaryToString((BYTE*) input, strlen(input), CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, buf, &retlen)) {
return NULL;
}
return strdup(buf);
}

Expand All @@ -307,8 +309,10 @@ std::string getLocalPipeName(const char *pipe_name)
} else {
std::string ret(pipe_name);
char *encoded = b64encode(user_name_buf);
ret += encoded;
free(encoded);
if (encoded) {
ret += encoded;
free(encoded);
}
return ret;
}
}
Expand Down

0 comments on commit e219727

Please sign in to comment.