[libc-commits] [libc] [libc][stdio] Add support for the %m modifier (PR #218312)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Tue Aug 25 16:47:52 PDT 2026
================
@@ -40,8 +47,27 @@ int convert_string(Reader<T> *reader, const FormatSection &to_conv) {
}
}
- char *output = reinterpret_cast<char *>(to_conv.output_ptr);
-
+ char *output;
+#ifndef LIBC_COPT_SCANF_DISABLE_ALLOCATION
+ size_t alloc_size;
+ AllocChecker ac;
+ if ((to_conv.flags & NO_WRITE) == 0 && (to_conv.flags & ALLOCATE) != 0) {
+ if (to_conv.conv_name == 'c')
+ alloc_size = max_width + 1;
+ else
+ alloc_size =
+ (max_width < ALLOCATION_BASE) ? max_width + 1 : ALLOCATION_BASE;
+ output = new (ac) char[alloc_size];
+ if (!ac) {
+ libc_errno = ENOMEM;
----------------
michaelrj-google wrote:
setting errno in an internal function like this isn't allowed in LLVM-libc. Returning the allocation failure error code is enough. Here and below.
https://github.com/llvm/llvm-project/pull/218312
More information about the libc-commits
mailing list