[Mesa-dev] [PATCH 2/7] util/mesa-sha1: allow to finish without taking the result

Grazvydas Ignotas notasas at gmail.com
Sun Mar 12 18:32:03 UTC 2017


Useful if we just want to free the context, in error paths for example.

Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
---
 src/util/mesa-sha1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c
index 2c47465..66be707 100644
--- a/src/util/mesa-sha1.c
+++ b/src/util/mesa-sha1.c
@@ -66,7 +66,8 @@ _mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
 {
    SHA1_CTX *sha1_ctx = (SHA1_CTX *) ctx;
 
-   SHA1Final(result, sha1_ctx);
+   if (result)
+      SHA1Final(result, sha1_ctx);
    free(sha1_ctx);
    return 1;
 }
-- 
2.7.4



More information about the mesa-dev mailing list