简体   繁体   中英

Branch condition evaluates to a garbage value when dereferencing a pointer to a pointer

I'm trying to clean up some issues from xcode's analyzer. One I haven't found a solution to is the "Branch condition evaluates to a garbage value". It's occurring in the following way:

int methodToCloseMyDatabase(sqlite3 **myDatabase, const char *callingFunctionName)
{
    if (myDatabase)
    {
        if (*myDatabase)  // The warning is thrown here
        {
           // Do something
        }
    }
}

This error sounds to me as if CLang has analyzed your code and found that *myDatabase is not set to anything.

It could even be that the analyzer has found a possible code branch that does not set the value.

How did you set myDatabase ? You probably forgot to initialize it correctly, so it points to arbitrary place in memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM