| Bug #10202 | Potential memory leak in make_empty_rec | ||
|---|---|---|---|
| Submitted: | 27 Apr 2005 13:41 | Modified: | 29 Apr 2005 14:04 |
| Reporter: | Mikael Ronström | Email Updates: | |
| Status: | Won't fix | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0-bk (2005-02-04) | OS: | MacOS (Mac OS X 10.3) |
| Assigned to: | Michael Widenius | CPU Architecture: | Any |
[28 Apr 2005 12:46]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/24449
[29 Apr 2005 14:04]
Michael Widenius
This is not a bug as regfield is allocated with sql_alloc() and thus doesn't have to be freed. I have now deleted 'delete regfield' from the source and added a comment instead.

Description: In make_empty_rec there is an obvious memory leak when returning from the routine in error How to repeat: Found by code review, don't know how to repeat Suggested fix: Code before fix: if (field->def && (regfield->real_type() != FIELD_TYPE_YEAR || field->def->val_int() != 0)) { if (field->def->save_in_field(regfield, 1)) { my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name); error= 1; goto err; } } Fixed code: if (field->def && (regfield->real_type() != FIELD_TYPE_YEAR || field->def->val_int() != 0)) { if (field->def->save_in_field(regfield, 1)) { my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name); error= 1; delete regfield; //To avoid memory leak goto err; } }