[SERVER-11541] Coverity analysis defect 15733: Allocation too small for type Created: 04/Nov/13  Updated: 19/May/14  Resolved: 14/Nov/13

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: auto Assignee: Benety Goh
Resolution: Won't Fix Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

A new defect has been detected and assigned to matt.kangas@10gen.com in Coverity Connect http://coverity.mongodb.com//sourcebrowser.htm?projectId=10001#mergedDefectId=15733
The defect was flagged by checker SIZECHECK in
file /src/mongo/db/exec/2d.cpp
function mongo::TwoD::work(long *)
and this ticket was created by matt.kangas@10gen.com

It's complaining about line 68 in 2d.cpp
https://github.com/mongodb/mongo/blame/master/src/mongo/db/exec/2d.cpp#L66-L70

 _am = static_cast<TwoDAccessMethod*>( collection->getIndexCatalog()->getIndex( _descriptor ) );

CID 15733 (#3-2 of 3): Allocation too small for type (SIZECHECK)10. size_error: Allocating 72 bytes to pointer of type mongo::TwoDAccessMethod, which needs at least 112 bytes.



 Comments   
Comment by Benety Goh [ 14/Nov/13 ]

the downcast in the code is correct. the result from the index catalog may be a pointer to the base type IndexMethod but the index catalog internally is creating 2DAccessMethod object.

Generated at Thu Feb 08 03:26:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.