apps/apps.c:1494: error: NULL_DEREFERENCE
  pointer `store` last assigned on line 1467 could be null and is dereferenced by call to `X509_STORE_free()` at line 1494, column 5.
Showing all 4 steps of the trace


apps/apps.c:1463:1: start of procedure setup_verify()
1461.   }
1462.   
1463. > X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
1464.   {
1465.       X509_STORE *store;

apps/apps.c:1467:11: Taking true branch
1465.       X509_STORE *store;
1466.       X509_LOOKUP *lookup;
1467.       if (!(store = X509_STORE_new()))
                  ^
1468.           goto end;
1469.       lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());

apps/apps.c:1493:2: 
1491.       ERR_clear_error();
1492.       return store;
1493. >  end:
1494.       X509_STORE_free(store);
1495.       return NULL;

apps/apps.c:1494:5: 
1492.       return store;
1493.    end:
1494. >     X509_STORE_free(store);
1495.       return NULL;
1496.   }

X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
{
    X509_STORE *store;
    X509_LOOKUP *lookup;
    if (!(store = X509_STORE_new()))
        goto end;
    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
    if (lookup == NULL)
        goto end;
    if (CAfile) {
        if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) {
            BIO_printf(bp, "Error loading file %s\n", CAfile);
            goto end;
        }
    } else
        X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
    if (lookup == NULL)
        goto end;
    if (CApath) {
        if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) {
            BIO_printf(bp, "Error loading directory %s\n", CApath);
            goto end;
        }
    } else
        X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
    ERR_clear_error();
    return store;
 end:
    X509_STORE_free(store);
    return NULL;
}
['X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)\n{\n    X509_STORE *store;\n    X509_LOOKUP *lookup;\n    if (!(store = X509_STORE_new()))\n        goto end;\n    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());\n    if (lookup == NULL)\n        goto end;\n    if (CAfile) {\n        if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) {\n            BIO_printf(bp, "Error loading file %s\\n", CAfile);\n            goto end;\n        }\n    } else\n        X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);\n    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());\n    if (lookup == NULL)\n        goto end;\n    if (CApath) {\n        if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) {\n            BIO_printf(bp, "Error loading directory %s\\n", CApath);\n            goto end;\n        }\n    } else\n        X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);\n    ERR_clear_error();\n    return store;\n end:\n    X509_STORE_free(store);\n    return NULL;\n}']