planetarium/rocksdb-sharp

RocksDb.ctor() occurs if path parameter is null

Open

#3 opened on Jan 27, 2021

 (0 comments) (0 reactions) (0 assignees)C# (3 forks)auto 404
buggood first issue

Repository metrics

Stars
 (4 stars)
PR merge metrics
 (PR metrics pending)

Description

When calling RocksDb's constructor with with null path parameter, it occurs System.AccessViolationException.

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at RocksDbSharp.Native.rocksdb_open(IntPtr, System.String)
   at RocksDbSharp.RocksDb.Open(RocksDbSharp.OptionsHandle, System.String)
   at RocksDBTool.Program+<Main>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
   at RocksDBTool.Program.Main(System.String[])
   at RocksDBTool.Program.<Main>(System.String[])

It should check it is null and throw System.ArgumentNullException. https://github.com/planetarium/rocksdb-sharp/blob/ccaf2184464963b565f7cfb9627cdf4734434af6/RocksDbSharp/RocksDb.cs#L42-L46

Contributor guide