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


crypto/mem_dbg.c:629:1: start of procedure print_leak_doall_arg()
627.   } MEM_LEAK;
628.   
629. > static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
630.   {
631.       char buf[1024];

crypto/mem_dbg.c:632:5: 
630.   {
631.       char buf[1024];
632. >     char *bufp = buf;
633.       APP_INFO *amip;
634.       int ami_cnt;

crypto/mem_dbg.c:635:5: 
633.       APP_INFO *amip;
634.       int ami_cnt;
635. >     struct tm *lcl = NULL;
636.       CRYPTO_THREADID ti;
637.   

crypto/mem_dbg.c:640:9: Taking false branch
638.   #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
639.   
640.       if (m->addr == (char *)l->bio)
               ^
641.           return;
642.   

crypto/mem_dbg.c:643:9: Taking true branch
641.           return;
642.   
643.       if (options & V_CRYPTO_MDEBUG_TIME) {
               ^
644.           lcl = localtime(&m->time);
645.   

crypto/mem_dbg.c:644:9: 
642.   
643.       if (options & V_CRYPTO_MDEBUG_TIME) {
644. >         lcl = localtime(&m->time);
645.   
646.           BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",

crypto/mem_dbg.c:646:9: 
644.           lcl = localtime(&m->time);
645.   
646. >         BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
647.                        lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
648.           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)
        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=%08lX\n",
                 m->num, (unsigned long)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)
        return;
    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
}
['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        return;\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=%08lX\\n",\n                 m->num, (unsigned long)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        return;\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#ifdef LEVITTE_DEBUG_MEM\n    if (amip) {\n        fprintf(stderr, "Thread switch detected in backtrace!!!!\\n");\n        abort();\n    }\n#endif\n}']