Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11
-
None
Description
The to_string() methods of Temporal_hybrid, Interval_DDhhmmssff, Time, Date and Datetime in sql/sql_type.h all have the same body:
str->set_charset(&my_charset_numeric);
|
if (!str->alloc(MAX_DATE_STRING_REP_LENGTH)) |
str->length(my_TIME_to_str(this, const_cast<char*>(str->ptr()), dec)); |
return str; |
When String::alloc() fails (out of memory) the length is not set, but str is still returned as success. The caller then uses a String whose buffer may be NULL and whose length is whatever it was before.
Expected: return NULL on allocation failure, like the !is_valid_temporal() case.
The body is copied five times and only the formatter differs, so it is worth factoring into one helper so that a fix cannot miss a copy.
Present in 10.11 and later.
Found during review of MDEV-25529 (https://github.com/MariaDB/server/pull/5294); the code predates that change.
Attachments
Issue Links
- relates to
-
MDEV-25529 Auto-create: Pre-existing historical data is not partitioned as specified by ALTER
-
- In Testing
-