File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -144,14 +144,6 @@ template <typename T> LIBC_INLINE constexpr TypeDesc type_desc_from_type() {
144144
145145// This is the value to be returned by conversions when no error has occurred.
146146constexpr int WRITE_OK = 0 ;
147- // These are the printf return values for when an error has occurred. They are
148- // all negative, and should be distinct.
149- // constexpr int FILE_WRITE_ERROR = -1;
150- // constexpr int FILE_STATUS_ERROR = -2;
151- // constexpr int NULLPTR_WRITE_ERROR = -3;
152- // constexpr int INT_CONVERSION_ERROR = -4;
153- // constexpr int FIXED_POINT_CONVERSION_ERROR = -5;
154- // constexpr int ALLOCATION_ERROR = -6;
155147} // namespace printf_core
156148} // namespace LIBC_NAMESPACE_DECL
157149
Original file line number Diff line number Diff line change @@ -112,4 +112,20 @@ TEST(LlvmLibcFPrintfTest, CharsWrittenOverflow) {
112112 ASSERT_ERRNO_EQ (EOVERFLOW);
113113
114114 EXPECT_EQ (printf_test::fclose (file), 0 );
115- }
115+ }
116+
117+ #ifndef LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS
118+ TEST (LlvmLibcFPrintfTest, NullPtrCheck) {
119+ const char *FILENAME = APPEND_LIBC_TEST (" fprintf_nullptr.test" );
120+ auto FILE_PATH = libc_make_test_file_path (FILENAME);
121+
122+ ::FILE *file = printf_test::fopen (FILE_PATH, " w" );
123+ ASSERT_FALSE (file == nullptr );
124+
125+ int ret = LIBC_NAMESPACE::fprintf (file, " hello %n" , (int *)nullptr );
126+ EXPECT_LT (ret, 0 );
127+ ASSERT_ERRNO_EQ (EINVAL);
128+
129+ ASSERT_EQ (printf_test::fclose (file), 0 );
130+ }
131+ #endif // LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS
You can’t perform that action at this time.
0 commit comments