X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Frsa.c;h=0a8e198d8ed1ef0fda8cd3498e8a409fd0965041;hp=c8b05e60ce1699e2666a730791b09e6c92cee13a;hb=68dc682499ea3fe27d909c946d7abd39062d6efd;hpb=222561fe8ef510f336417a666f69f81ddc9b8fe4 diff --git a/apps/rsa.c b/apps/rsa.c index c8b05e60ce..0a8e198d8e 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -344,19 +344,14 @@ int rsa_main(int argc, char **argv) } # ifndef OPENSSL_NO_RC4 else if (outformat == FORMAT_NETSCAPE) { - unsigned char *p, *pp; - int size; + unsigned char *p, *save; + int size = i2d_RSA_NET(rsa, NULL, NULL, 0); - i = 1; - size = i2d_RSA_NET(rsa, NULL, NULL, 0); - if ((p = OPENSSL_malloc(size)) == NULL) { - BIO_printf(bio_err, "Memory allocation failure\n"); - goto end; - } - pp = p; + save = p = app_malloc(size, "RSA i2d buffer"); i2d_RSA_NET(rsa, &p, NULL, 0); - BIO_write(out, (char *)pp, size); - OPENSSL_free(pp); + BIO_write(out, (char *)save, size); + OPENSSL_free(save); + i = 1; } # endif else if (outformat == FORMAT_PEM) {