facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.71k stars 6.33k forks source link

Malloc returned values doesn't checked #13099

Open NoamRabi20 opened 3 weeks ago

NoamRabi20 commented 3 weeks ago

Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://groups.google.com/forum/#!forum/rocksdb or https://www.facebook.com/groups/rocksdb.dev

Expected behavior

Malloc return values should be verified, and in case of unsuccessful malloc, error should be propagate

Actual behavior

unsuccessful malloc will return null, and the following action will cause crash

Steps to reproduce the behavior

run on low memory system

examples

db/c.cc (7 instances) cache/lru.cache.cc (2 instances)

gitlijian commented 2 weeks ago

hi, @NoamRabi20 Is this the way to modify it? If possible, I will perform exception detection at each call to malloc. image

NoamRabi20 commented 2 weeks ago

yes, this is good approach, just need to make sure at each call how the code handle errors (return null in this specific case) it may be different between calls