Bug #106008 thd in condition 'if (!(thd = new THD)) ' is never NULL
Submitted: 30 Dec 2021 9:43 Modified: 3 Jan 2022 7:29
Reporter: Cheng Zhou Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[30 Dec 2021 9:43] Cheng Zhou
Description:
In MySQL source code, the condition 'if (!(thd = new THD)) ' is used in several places. But thd is never NULL even if it fails to malloc memory. 'new' throws a bad_alloc exception on failure. 

How to repeat:
no
[30 Dec 2021 10:25] Cheng Zhou
modifiy version
[31 Dec 2021 0:25] Cheng Zhou
Use 'thd = new (std::nothrow) THD' instead of 'thd = new THD'.
[3 Jan 2022 7:29] MySQL Verification Team
Hello Cheng Zhou,

Thank you for the report and feedback.

regards,
Umesh