Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssl libmosquitto中仍然可以到达的块_Ssl_Memory Leaks_Libmosquitto - Fatal编程技术网

Ssl libmosquitto中仍然可以到达的块

Ssl libmosquitto中仍然可以到达的块,ssl,memory-leaks,libmosquitto,Ssl,Memory Leaks,Libmosquitto,我正在处理下面的示例,但当我使用valgrind运行此程序时,内存泄漏 static struct mosquitto *m = NULL; int main(){ mosquitto_lib_init(); printf("LIBMOSQUITTO %d\n", LIBMOSQUITTO_VERSION_NUMBER); if ((m = mosquitto_new("rtr", 1, NULL)) == NULL) { fprintf(stder

我正在处理下面的示例,但当我使用valgrind运行此程序时,内存泄漏

static struct mosquitto *m = NULL;

int main(){

    mosquitto_lib_init();
    printf("LIBMOSQUITTO %d\n", LIBMOSQUITTO_VERSION_NUMBER);

    if ((m = mosquitto_new("rtr", 1, NULL)) == NULL) {
        fprintf(stderr, "Out of memory.\n");
        exit(1);
    }

    int rc = mosquitto_tls_set(m,
            "/home/ca.crt",     /* cafile */
            NULL,           /* capath */
            "/home/client.crt",     /* certfile */
            "/home/client.key",     /* keyfile */
            NULL            /* pw_callback() */
            );

    if (rc != MOSQ_ERR_SUCCESS) {
        fprintf(stderr, "Cannot set TLS CA: %s (check path names)\n",
                mosquitto_strerror(rc));
        exit(3);
    }
#if 1
    mosquitto_tls_opts_set(m,
            SSL_VERIFY_PEER,
            NULL,           /* tls_version: "tlsv1.2", "tlsv1" */
            NULL            /* ciphers */
            );
    mosquitto_tls_insecure_set(m, 1);
#endif
    if ((rc = mosquitto_connect(m, "localhost", 8884, 20)) != MOSQ_ERR_SUCCESS) {
        fprintf(stderr, "%d: Unable to connect: %s\n", rc,
                mosquitto_strerror(rc));
        perror("");
        exit(2);
    }

    //mosquitto_loop_forever(m, -1, 1);
    mosquitto_destroy(m);
    mosquitto_lib_cleanup();
}
Valgrind输出:

==4264== HEAP SUMMARY:
==4264==     in use at exit: 64 bytes in 2 blocks
==4264==   total heap usage: 4,913 allocs, 4,911 frees, 364,063 bytes allocated
==4264== 
==4264== LEAK SUMMARY:
==4264==    definitely lost: 0 bytes in 0 blocks
==4264==    indirectly lost: 0 bytes in 0 blocks
==4264==      possibly lost: 0 bytes in 0 blocks
==4264==    still reachable: 64 bytes in 2 blocks
==4264==         suppressed: 0 bytes in 0 blocks
==4264== Rerun with --leak-check=full to see details of leaked memory
==4264== 
==4264== For counts of detected and suppressed errors, rerun with: -v
==4264== Use --track-origins=yes to see where uninitialised values come from
==4264== ERROR SUMMARY: 13582 errors from 542 contexts (suppressed: 0 from 0)

如何修复这些问题?

==4264==重新运行时使用--leak check=full查看泄漏内存的详细信息
-它会告诉您下一步该怎么做。此外,它还清楚地显示没有泄漏-所有的块都“仍然可以访问”。
==4264==重新运行时使用--leak check=full查看泄漏内存的详细信息
-它确实可以告诉你下一步该做什么。此外,它还清楚地显示你没有泄漏-所有的区块“仍然可以到达”。