A lookup in a splay tree does move the looked up entry to the root of
the tree. This means the tree structure is modified on lookup alone.
Obviously the tree structure is also modified when inserting new nodes.
For both of these reasons access to the f{Node|Ino}Tree needs to be
locked on lookup and insert.
Fixes crashes when the tree is concurrently modified by multiple threads
accessing the same exfat volume.
In addition this protects the fNextId field that hands out new inode
ids.
... in situations where a NULL pointer dereference was vital to the
functioning of the method we use a stronger assert that throws an
exception on failure. This is accomplished by a new method in
Utilities.cpp, ThrowOnAssert().
None of these conditions should ever be true, if they are it means that
the code is written improperly and would have resulted in a NULL
dereference and undefined behavior (most likely a crash) before.
Most instances of ThrowOnAssert() either replace an ASSERT followed
by a dereference or an early return that covered the error.
Also remove _ThrowOnErrorWithMessage() which wasn't being used.
To prevent recoverable NULL pointer dereferences. Dereferencing a
NULL pointer is undefined behavior and should be avoided.
Unrecoverable NULL checks will be dealt with in the next commit.
By using a BString we can keep track of the string length instead of
calculating the length after hoping that sprintf() works or doing a
bunch more work to check the return values using either snprintf()
or asprintf(). sprintf() was not bounds checked either. As an added
bonus we no longer have to use an arbitrary 1024 bytes size buffer.
CID 991605
Instead of passing the box in we can just use FindView to get it,
that's what other methods do. Also, check if removeButton exists
in AddAttrRow() first instead of doing it in this method.
The CIDs are about mkdir, we want to check that either the command
succeeded or failed because the directory already exists.
However, we also want to check the return value of find_directory()
and Append() to make sure they succeeded as well.