crypto/mem_dbg.c:663: error: NULL_DEREFERENCE
  pointer `lcl` last assigned on line 660 could be null and is dereferenced at line 663, column 22.
Showing all 7 steps of the trace


crypto/mem_dbg.c:642:1: start of procedure print_leak_doall_arg()
640.   } MEM_LEAK;
641.   
642. > static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
643.   {
644.       char buf[1024];

crypto/mem_dbg.c:645:5: 
643.   {
644.       char buf[1024];
645. >     char *bufp = buf;
646.       APP_INFO *amip;
647.       int ami_cnt;

crypto/mem_dbg.c:648:5: 
646.       APP_INFO *amip;
647.       int ami_cnt;
648. >     struct tm *lcl = NULL;
649.       CRYPTO_THREADID ti;
650.   

crypto/mem_dbg.c:654:9: Taking false branch
652.   
653.       /* Is one "leak" the BIO we were given? */
654.       if (m->addr == (char *)l->bio) {
               ^
655.           l->seen = 1;
656.           return;

crypto/mem_dbg.c:659:9: Taking true branch
657.       }
658.   
659.       if (options & V_CRYPTO_MDEBUG_TIME) {
               ^
660.           lcl = localtime(&m->time);
661.   

crypto/mem_dbg.c:660:9: 
658.   
659.       if (options & V_CRYPTO_MDEBUG_TIME) {
660. >         lcl = localtime(&m->time);
661.   
662.           BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",

crypto/mem_dbg.c:662:9: 
660.           lcl = localtime(&m->time);
661.   
662. >         BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
663.                        lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
664.           bufp += strlen(bufp);

static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
{
    char buf[1024];
    char *bufp = buf;
    APP_INFO *amip;
    int ami_cnt;
    struct tm *lcl = NULL;
    CRYPTO_THREADID ti;
#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
    if (m->addr == (char *)l->bio) {
        l->seen = 1;
        return;
    }
    if (options & V_CRYPTO_MDEBUG_TIME) {
        lcl = localtime(&m->time);
        BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
                     lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
        bufp += strlen(bufp);
    }
    BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
                 m->order, m->file, m->line);
    bufp += strlen(bufp);
    if (options & V_CRYPTO_MDEBUG_THREAD) {
        BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ",
                     CRYPTO_THREADID_hash(&m->threadid));
        bufp += strlen(bufp);
    }
    BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\n",
                 m->num, m->addr);
    bufp += strlen(bufp);
    BIO_puts(l->bio, buf);
    l->chunks++;
    l->bytes += m->num;
    amip = m->app_info;
    ami_cnt = 0;
    if (amip) {
        CRYPTO_THREADID_cpy(&ti, &amip->threadid);
        do {
            int buf_len;
            int info_len;
            ami_cnt++;
            memset(buf, '>', ami_cnt);
            BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
                         " thread=%lu, file=%s, line=%d, info=\"",
                         CRYPTO_THREADID_hash(&amip->threadid), amip->file,
                         amip->line);
            buf_len = strlen(buf);
            info_len = strlen(amip->info);
            if (128 - buf_len - 3 < info_len) {
                memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
                buf_len = 128 - 3;
            } else {
                BUF_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
                buf_len = strlen(buf);
            }
            BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
            BIO_puts(l->bio, buf);
            amip = amip->next;
        }
        while (amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
    }
#ifdef LEVITTE_DEBUG_MEM
    if (amip) {
        fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
        abort();
    }
#endif
#if defined(CRYPTO_MDEBUG_BACKTRACE) && defined(__GNUC__)
    {
        size_t i;
        char **strings = backtrace_symbols(m->array, m->array_siz);
        for (i = 0; i < m->array_siz; i++)
            fprintf(stderr, "##> %s\n", strings[i]);
        free(strings);
    }
#endif
}
['static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)\n{\n    char buf[1024];\n    char *bufp = buf;\n    APP_INFO *amip;\n    int ami_cnt;\n    struct tm *lcl = NULL;\n    CRYPTO_THREADID ti;\n#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))\n    if (m->addr == (char *)l->bio) {\n        l->seen = 1;\n        return;\n    }\n    if (options & V_CRYPTO_MDEBUG_TIME) {\n        lcl = localtime(&m->time);\n        BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",\n                     lcl->tm_hour, lcl->tm_min, lcl->tm_sec);\n        bufp += strlen(bufp);\n    }\n    BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",\n                 m->order, m->file, m->line);\n    bufp += strlen(bufp);\n    if (options & V_CRYPTO_MDEBUG_THREAD) {\n        BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ",\n                     CRYPTO_THREADID_hash(&m->threadid));\n        bufp += strlen(bufp);\n    }\n    BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\\n",\n                 m->num, m->addr);\n    bufp += strlen(bufp);\n    BIO_puts(l->bio, buf);\n    l->chunks++;\n    l->bytes += m->num;\n    amip = m->app_info;\n    ami_cnt = 0;\n    if (amip) {\n        CRYPTO_THREADID_cpy(&ti, &amip->threadid);\n        do {\n            int buf_len;\n            int info_len;\n            ami_cnt++;\n            memset(buf, \'>\', ami_cnt);\n            BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,\n                         " thread=%lu, file=%s, line=%d, info=\\"",\n                         CRYPTO_THREADID_hash(&amip->threadid), amip->file,\n                         amip->line);\n            buf_len = strlen(buf);\n            info_len = strlen(amip->info);\n            if (128 - buf_len - 3 < info_len) {\n                memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);\n                buf_len = 128 - 3;\n            } else {\n                BUF_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);\n                buf_len = strlen(buf);\n            }\n            BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\\"\\n");\n            BIO_puts(l->bio, buf);\n            amip = amip->next;\n        }\n        while (amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));\n    }\n#ifdef LEVITTE_DEBUG_MEM\n    if (amip) {\n        fprintf(stderr, "Thread switch detected in backtrace!!!!\\n");\n        abort();\n    }\n#endif\n#if defined(CRYPTO_MDEBUG_BACKTRACE) && defined(__GNUC__)\n    {\n        size_t i;\n        char **strings = backtrace_symbols(m->array, m->array_siz);\n        for (i = 0; i < m->array_siz; i++)\n            fprintf(stderr, "##> %s\\n", strings[i]);\n        free(strings);\n    }\n#endif\n}']