apps/speed.c:3035: error: NULL_DEREFERENCE
  pointer `fds` last assigned on line 3025 could be null and is dereferenced at line 3035, column 13.
Showing all 19 steps of the trace


apps/speed.c:3018:1: start of procedure do_multi()
3016.   }
3017.   
3018. > static int do_multi(int multi)
3019.   {
3020.       int n;

apps/speed.c:3023:5: 
3021.       int fd[2];
3022.       int *fds;
3023. >     static char sep[] = ":";
3024.   
3025.       fds = malloc(sizeof(*fds) * multi);

apps/speed.c:3025:5: 
3023.       static char sep[] = ":";
3024.   
3025. >     fds = malloc(sizeof(*fds) * multi);
3026.       for (n = 0; n < multi; ++n) {
3027.           if (pipe(fd) == -1) {

apps/speed.c:3026:10: 
3024.   
3025.       fds = malloc(sizeof(*fds) * multi);
3026. >     for (n = 0; n < multi; ++n) {
3027.           if (pipe(fd) == -1) {
3028.               BIO_printf(bio_err, "pipe failure\n");

apps/speed.c:3026:17: Loop condition is true. Entering loop body
3024.   
3025.       fds = malloc(sizeof(*fds) * multi);
3026.       for (n = 0; n < multi; ++n) {
                        ^
3027.           if (pipe(fd) == -1) {
3028.               BIO_printf(bio_err, "pipe failure\n");

apps/speed.c:3027:13: Taking false branch
3025.       fds = malloc(sizeof(*fds) * multi);
3026.       for (n = 0; n < multi; ++n) {
3027.           if (pipe(fd) == -1) {
                    ^
3028.               BIO_printf(bio_err, "pipe failure\n");
3029.               exit(1);

apps/speed.c:3031:9: 
3029.               exit(1);
3030.           }
3031. >         fflush(stdout);
3032.           (void)BIO_flush(bio_err);
3033.           if (fork()) {

apps/speed.c:3032:15: 
3030.           }
3031.           fflush(stdout);
3032. >         (void)BIO_flush(bio_err);
3033.           if (fork()) {
3034.               close(fd[1]);

crypto/bio/bio_lib.c:509:1: start of procedure BIO_ctrl()
  507.   }
  508.   
  509. > long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
  510.   {
  511.       long ret;

crypto/bio/bio_lib.c:513:9: Taking false branch
  511.       long ret;
  512.   
  513.       if (b == NULL)
                 ^
  514.           return 0;
  515.   

crypto/bio/bio_lib.c:516:10: Taking false branch
  514.           return 0;
  515.   
  516.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
                  ^
  517.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  518.           return -2;

crypto/bio/bio_lib.c:516:33: Taking true branch
  514.           return 0;
  515.   
  516.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
                                         ^
  517.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  518.           return -2;

crypto/bio/bio_lib.c:517:9: Skipping ERR_put_error(): empty list of specs
  515.   
  516.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
  517.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
                 ^
  518.           return -2;
  519.       }

crypto/bio/bio_lib.c:518:9: 
  516.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
  517.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  518. >         return -2;
  519.       }
  520.   

crypto/bio/bio_lib.c:534:1: return from a call to BIO_ctrl
  532.   
  533.       return ret;
  534. > }
  535.   
  536.   long BIO_callback_ctrl(BIO *b, int cmd,

apps/speed.c:3032:9: 
3030.           }
3031.           fflush(stdout);
3032. >         (void)BIO_flush(bio_err);
3033.           if (fork()) {
3034.               close(fd[1]);

apps/speed.c:3033:13: Taking true branch
3031.           fflush(stdout);
3032.           (void)BIO_flush(bio_err);
3033.           if (fork()) {
                    ^
3034.               close(fd[1]);
3035.               fds[n] = fd[0];

apps/speed.c:3034:13: 
3032.           (void)BIO_flush(bio_err);
3033.           if (fork()) {
3034. >             close(fd[1]);
3035.               fds[n] = fd[0];
3036.           } else {

apps/speed.c:3035:13: 
3033.           if (fork()) {
3034.               close(fd[1]);
3035. >             fds[n] = fd[0];
3036.           } else {
3037.               close(fd[0]);

static int do_multi(int multi)
{
    int n;
    int fd[2];
    int *fds;
    static char sep[] = ":";
    fds = malloc(sizeof(*fds) * multi);
    for (n = 0; n < multi; ++n) {
        if (pipe(fd) == -1) {
            BIO_printf(bio_err, "pipe failure\n");
            exit(1);
        }
        fflush(stdout);
        (void)BIO_flush(bio_err);
        if (fork()) {
            close(fd[1]);
            fds[n] = fd[0];
        } else {
            close(fd[0]);
            close(1);
            if (dup(fd[1]) == -1) {
                BIO_printf(bio_err, "dup failed\n");
                exit(1);
            }
            close(fd[1]);
            mr = 1;
            usertime = 0;
            free(fds);
            return 0;
        }
        printf("Forked child %d\n", n);
    }
    for (n = 0; n < multi; ++n) {
        FILE *f;
        char buf[1024];
        char *p;
        f = fdopen(fds[n], "r");
        while (fgets(buf, sizeof buf, f)) {
            p = strchr(buf, '\n');
            if (p)
                *p = '\0';
            if (buf[0] != '+') {
                BIO_printf(bio_err,
                           "Don't understand line '%s' from child %d\n", buf,
                           n);
                continue;
            }
            printf("Got: %s from %d\n", buf, n);
            if (strncmp(buf, "+F:", 3) == 0) {
                int alg;
                int j;
                p = buf + 3;
                alg = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                for (j = 0; j < SIZE_NUM; ++j)
                    results[alg][j] += atof(sstrsep(&p, sep));
            } else if (strncmp(buf, "+F2:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                rsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                rsa_results[k][1] += d;
            }
# ifndef OPENSSL_NO_DSA
            else if (strncmp(buf, "+F3:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                dsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                dsa_results[k][1] += d;
            }
# endif
# ifndef OPENSSL_NO_EC
            else if (strncmp(buf, "+F4:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                ecdsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                ecdsa_results[k][1] += d;
            } else if (strncmp(buf, "+F5:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                ecdh_results[k][0] += d;
            }
# endif
            else if (strncmp(buf, "+H:", 3) == 0) {
                ;
            } else
                BIO_printf(bio_err, "Unknown type '%s' from child %d\n", buf,
                           n);
        }
        fclose(f);
    }
    free(fds);
    return 1;
}
['static int do_multi(int multi)\n{\n    int n;\n    int fd[2];\n    int *fds;\n    static char sep[] = ":";\n    fds = malloc(sizeof(*fds) * multi);\n    for (n = 0; n < multi; ++n) {\n        if (pipe(fd) == -1) {\n            BIO_printf(bio_err, "pipe failure\\n");\n            exit(1);\n        }\n        fflush(stdout);\n        (void)BIO_flush(bio_err);\n        if (fork()) {\n            close(fd[1]);\n            fds[n] = fd[0];\n        } else {\n            close(fd[0]);\n            close(1);\n            if (dup(fd[1]) == -1) {\n                BIO_printf(bio_err, "dup failed\\n");\n                exit(1);\n            }\n            close(fd[1]);\n            mr = 1;\n            usertime = 0;\n            free(fds);\n            return 0;\n        }\n        printf("Forked child %d\\n", n);\n    }\n    for (n = 0; n < multi; ++n) {\n        FILE *f;\n        char buf[1024];\n        char *p;\n        f = fdopen(fds[n], "r");\n        while (fgets(buf, sizeof buf, f)) {\n            p = strchr(buf, \'\\n\');\n            if (p)\n                *p = \'\\0\';\n            if (buf[0] != \'+\') {\n                BIO_printf(bio_err,\n                           "Don\'t understand line \'%s\' from child %d\\n", buf,\n                           n);\n                continue;\n            }\n            printf("Got: %s from %d\\n", buf, n);\n            if (strncmp(buf, "+F:", 3) == 0) {\n                int alg;\n                int j;\n                p = buf + 3;\n                alg = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                for (j = 0; j < SIZE_NUM; ++j)\n                    results[alg][j] += atof(sstrsep(&p, sep));\n            } else if (strncmp(buf, "+F2:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                rsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                rsa_results[k][1] += d;\n            }\n# ifndef OPENSSL_NO_DSA\n            else if (strncmp(buf, "+F3:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                dsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                dsa_results[k][1] += d;\n            }\n# endif\n# ifndef OPENSSL_NO_EC\n            else if (strncmp(buf, "+F4:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                ecdsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                ecdsa_results[k][1] += d;\n            } else if (strncmp(buf, "+F5:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                ecdh_results[k][0] += d;\n            }\n# endif\n            else if (strncmp(buf, "+H:", 3) == 0) {\n                ;\n            } else\n                BIO_printf(bio_err, "Unknown type \'%s\' from child %d\\n", buf,\n                           n);\n        }\n        fclose(f);\n    }\n    free(fds);\n    return 1;\n}', 'long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)\n{\n    long ret;\n    if (b == NULL)\n        return 0;\n    if ((b->method == NULL) || (b->method->ctrl == NULL)) {\n        BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    ret = b->method->ctrl(b, cmd, larg, parg);\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,\n                                larg, ret, NULL);\n    return ret;\n}']