mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-27 00:28:14 +00:00
Merge pull request #10781 from MarcZX10/marc/fix-printf-s-closed-stdout
fix(libc): fail printf_s on a closed standard output with EBADF
This commit is contained in:
2 files changed
+6
No files matched your search
@@ -714,6 +714,7 @@ int APS5_VABI snprintf_s_nid_postfix(char* buffer, size_t size, const char* form
|
||||
}
|
||||
|
||||
int APS5_VABI printf_s_nid_postfix(const char* format, ...) {
|
||||
if (!_Stdout_nid_postfix.IsOpen()) { errno = 9; return -1; }
|
||||
__builtin_sysv_va_list args;
|
||||
__builtin_sysv_va_start(args, format);
|
||||
const int result = LibcDetail::PrintWindows(format, args);
|
||||
@@ -754,6 +755,7 @@ int APS5_VABI snprintf_s_nid_postfix(char* buffer, size_t size, const char* form
|
||||
}
|
||||
|
||||
int APS5_VABI printf_s_nid_postfix(const char* format, ...) {
|
||||
if (!_Stdout_nid_postfix.IsOpen()) { errno = 9; return -1; }
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
const int result = RequiresGuestFormatting(format) ? LibcDetail::PrintWindows(format, args) : std::vfprintf(GuestStandardOutputFile_nid_no_patch(), format, args);
|
||||
|
||||
@@ -575,6 +575,10 @@ static int CheckClosedStandardOutput() {
|
||||
Require(printf_nid_postfix("%d", 1) == -1 && *__error_nid_postfix() == 9);
|
||||
Require(puts_nid_postfix("text") == -1 && *__error_nid_postfix() == 9);
|
||||
Require(PrintStandard("%d", 1) == -1 && *__error_nid_postfix() == 9);
|
||||
*__error_nid_postfix() = 0;
|
||||
Require(printf_s_nid_postfix("%d", 1) == -1 && *__error_nid_postfix() == 9);
|
||||
*__error_nid_postfix() = 0;
|
||||
Require(printf_s_nid_postfix("%p", nullptr) == -1 && *__error_nid_postfix() == 9);
|
||||
Require(fputs_nid_postfix("text", __stdoutp_nid_postfix) == -1 && *__error_nid_postfix() == 9);
|
||||
*__error_nid_postfix() = 0;
|
||||
Require(wprintf_nid_postfix(u"%d", 1) == -1 && *__error_nid_postfix() == 9);
|
||||
|
||||
Reference in new issue
Block a user