Get rid if the annoying warning
[openssl.git] / crypto / pem / pem_lib.c
index e921cc4c1286c694a2eae0e06eb221916103101b..565c3e54a5415833cc0f2c29cb1edf80e6b6abd9 100644 (file)
@@ -303,7 +303,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
 
        if ((dsize=i2d(x,NULL)) < 0)
                {
-               PEMerr(PEM_F_PEM_ASN1_WRITE_BIO,ERR_R_MALLOC_FAILURE);
+               PEMerr(PEM_F_PEM_ASN1_WRITE_BIO,ERR_R_ASN1_LIB);
                dsize=0;
                goto err;
                }
@@ -434,6 +434,7 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher)
        int o;
        const EVP_CIPHER *enc=NULL;
        char *p,c;
+       char **header_pp = &header;
 
        cipher->cipher=NULL;
        if ((header == NULL) || (*header == '\0') || (*header == '\n'))
@@ -480,7 +481,8 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher)
                PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO,PEM_R_UNSUPPORTED_ENCRYPTION);
                return(0);
                }
-       if (!load_iv((unsigned char **)&header,&(cipher->iv[0]),enc->iv_len)) return(0);
+       if (!load_iv((unsigned char **)header_pp,&(cipher->iv[0]),enc->iv_len))
+               return(0);
 
        return(1);
        }
@@ -537,7 +539,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
             long len)
        {
        int nlen,n,i,j,outl;
-       unsigned char *buf;
+       unsigned char *buf = NULL;
        EVP_ENCODE_CTX ctx;
        int reason=ERR_R_BUF_LIB;
        
@@ -557,7 +559,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
                        goto err;
                }
 
-       buf=(unsigned char *)OPENSSL_malloc(PEM_BUFSIZE*8);
+       buf = OPENSSL_malloc(PEM_BUFSIZE*8);
        if (buf == NULL)
                {
                reason=ERR_R_MALLOC_FAILURE;
@@ -578,12 +580,15 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
        EVP_EncodeFinal(&ctx,buf,&outl);
        if ((outl > 0) && (BIO_write(bp,(char *)buf,outl) != outl)) goto err;
        OPENSSL_free(buf);
+       buf = NULL;
        if (    (BIO_write(bp,"-----END ",9) != 9) ||
                (BIO_write(bp,name,nlen) != nlen) ||
                (BIO_write(bp,"-----\n",6) != 6))
                goto err;
        return(i+outl);
 err:
+       if (buf)
+               OPENSSL_free(buf);
        PEMerr(PEM_F_PEM_WRITE_BIO,reason);
        return(0);
        }