<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"> <span>No, you got that right, NULL being 'safe' to free varies with OS. <br><br>But - you aren't calling free() directly, THIS makes it safe. That's one of the other benefits of having objects allocated and released by internal functions rather than doing it directly.<br><br>void BN_MONT_CTX_free(BN_MONT_CTX *mont)<br>{<br>    if (mont == NULL)<br>        return;<br><br>    BN_clear_free(&(mont->RR));<br>    BN_clear_free(&(mont->N));<br>    BN_clear_free(&(mont->Ni));<br>    if (mont->flags & BN_FLG_MALLOCED)<br>        OPENSSL_free(mont);<br>}<br><br></span><br><font color="#990099">-----"openssl-dev" <<a target="_blank" href="mailto:openssl-dev-bounces@openssl.org">openssl-dev-bounces@openssl.org</a>> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">From: Bill Parker via RT <rt@openssl.org><br>Sent by: "openssl-dev" <openssl-dev-bounces@openssl.org><br>Date: 03/09/2016 07:53AM<br>Cc: <a target="_blank" href="mailto:openssl-dev@openssl.org">openssl-dev@openssl.org</a><br>Subject: Re: [openssl-dev] [openssl.org #4401] [PATCH] plug potential memory        leak(s) in OpenSSL 1.1 pre 4 in 'ec_lib.c'<br><br><div><font size="2" face="Courier New,Courier,monospace">I must be brain dead today, since free'ing something that is already NULL<br>is not a problem (geez)...<br><br>Heh<br><br>On Tue, Mar 8, 2016 at 12:01 PM, Salz, Rich via RT <<a target="_blank" href="mailto:rt@openssl.org">rt@openssl.org</a>> wrote:<br><br>><br>> > +               if (dest->mont_data != NULL)<br>> > +                   BN_MONT_CTX_free(dest->mont_data);<br>><br>> Free routines don't need to check for non-NULL.<br>><br>><br>> --<br>> Ticket here: <a href="http://rt.openssl.org/Ticket/Display.html?id=4401">http://rt.openssl.org/Ticket/Display.html?id=4401</a><br>> Please log in as guest with password guest if prompted<br>><br>><br><br>-- <br>Ticket here: <a href="http://rt.openssl.org/Ticket/Display.html?id=4401">http://rt.openssl.org/Ticket/Display.html?id=4401</a><br>Please log in as guest with password guest if prompted<br><br>-- <br>openssl-dev mailing list<br>To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-dev">https://mta.openssl.org/mailman/listinfo/openssl-dev</a><br><br></font></div></openssl-dev-bounces@openssl.org></rt@openssl.org></div></div></font><BR>