Opened 11 years ago
Closed 9 years ago
#5043 closed defect (duplicate)
Apparent bug in OGRFieldDefn assignment operator
Reported by: | bugpower | Owned by: | warmerdam |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | OGR_SF | Version: | 1.9.1 |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
I haven't researched it deeply, but here's how it looks.
This code works:
static void CreateStandardPolygonFields(OGRLayer *poLayer) { OGRFieldDefn field1("Name", OGRFieldType::OFTString); field1.SetWidth(32); poLayer->CreateField(&field1); OGRFieldDefn field2("Session", OGRFieldType::OFTString); field2.SetWidth(128); poLayer->CreateField(&field2); OGRFieldDefn field3("Time", OGRFieldType::OFTString); field3.SetWidth(32); poLayer->CreateField(&field3); OGRFieldDefn field5("Position stream", OGRFieldType::OFTString); field5.SetWidth(32); poLayer->CreateField(&field5); OGRFieldDefn field6("Area_km2", OGRFieldType::OFTReal); poLayer->CreateField(&field6); }
This one causes heap corruption on return:
static void CreateStandardPolygonFields(OGRLayer *poLayer) { OGRFieldDefn field("Name", OGRFieldType::OFTString); field.SetWidth(32); poLayer->CreateField(&field); field = OGRFieldDefn("Session", OGRFieldType::OFTString); field.SetWidth(32); poLayer->CreateField(&field); field = OGRFieldDefn("Time", OGRFieldType::OFTString); field.SetWidth(32); poLayer->CreateField(&field); field = OGRFieldDefn("Position stream", OGRFieldType::OFTString); field.SetWidth(32); poLayer->CreateField(&field); field = OGRFieldDefn("Area_km2", OGRFieldType::OFTReal); poLayer->CreateField(&field); }
The only difference is recycling the same "field" which should be okay.
Change History (6)
comment:1 by , 11 years ago
Component: | default → OGR_SF |
---|---|
Description: | modified (diff) |
comment:2 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I don't see an action item so I'm closing. Please reopen if you see something that needs to be done.
comment:3 by , 11 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Explaining.
(if compiles) it is expected to overwrite the existing local with a temporary. From there it should be equivalent. It is not, this is the symptom.
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:5 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:6 by , 9 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Dealt by #6100 (explicitly disabling copy constructor and assigment operator)
Note:
See TracTickets
for help on using tickets.
I've never seen something like:
before and I can't understand how it is intended to work.