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


crypto/mem_dbg.c:588:1: start of procedure print_leak_doall_arg()
586.   } MEM_LEAK;
587.   
588. > static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
589.   {
590.       char buf[1024];

crypto/mem_dbg.c:591:5: 
589.   {
590.       char buf[1024];
591. >     char *bufp = buf;
592.       APP_INFO *amip;
593.       int ami_cnt;

crypto/mem_dbg.c:594:5: 
592.       APP_INFO *amip;
593.       int ami_cnt;
594. >     struct tm *lcl = NULL;
595.       CRYPTO_THREADID ti;
596.   

crypto/mem_dbg.c:600:9: Taking false branch
598.   
599.       /* Is one "leak" the BIO we were given? */
600.       if (m->addr == (char *)l->bio) {
               ^
601.           l->seen = 1;
602.           return;

crypto/mem_dbg.c:605:9: Taking true branch
603.       }
604.   
605.       if (options & V_CRYPTO_MDEBUG_TIME) {
               ^
606.           lcl = localtime(&m->time);
607.   

crypto/mem_dbg.c:606:9: 
604.   
605.       if (options & V_CRYPTO_MDEBUG_TIME) {
606. >         lcl = localtime(&m->time);
607.   
608.           BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",

crypto/mem_dbg.c:608:9: 
606.           lcl = localtime(&m->time);
607.   
608. >         BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
609.                        lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
610.           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 {
                OPENSSL_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));
    }
#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                OPENSSL_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#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}']