From: doug Date: Wed, 29 Apr 2015 01:16:06 +0000 (+0000) Subject: free() can handle NULL. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1f4d25518eebe5e0e239f9f2026567bfd63d8e2a;p=openbsd free() can handle NULL. ok jsing@ --- diff --git a/lib/libssl/bs_cbs.c b/lib/libssl/bs_cbs.c index d7c0977cf3f..25305b9edd2 100644 --- a/lib/libssl/bs_cbs.c +++ b/lib/libssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.3 2015/04/25 15:28:47 doug Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.4 2015/04/29 01:16:06 doug Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -65,10 +65,8 @@ CBS_len(const CBS *cbs) int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) { - if (*out_ptr != NULL) { - free(*out_ptr); - *out_ptr = NULL; - } + free(*out_ptr); + *out_ptr = NULL; *out_len = 0; if (cbs->len == 0) @@ -85,9 +83,7 @@ CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) int CBS_strdup(const CBS *cbs, char **out_ptr) { - if (*out_ptr != NULL) - free(*out_ptr); - + free(*out_ptr); *out_ptr = strndup((const char*)cbs->data, cbs->len); return (*out_ptr != NULL); } diff --git a/lib/libssl/src/ssl/bs_cbs.c b/lib/libssl/src/ssl/bs_cbs.c index d7c0977cf3f..25305b9edd2 100644 --- a/lib/libssl/src/ssl/bs_cbs.c +++ b/lib/libssl/src/ssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.3 2015/04/25 15:28:47 doug Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.4 2015/04/29 01:16:06 doug Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -65,10 +65,8 @@ CBS_len(const CBS *cbs) int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) { - if (*out_ptr != NULL) { - free(*out_ptr); - *out_ptr = NULL; - } + free(*out_ptr); + *out_ptr = NULL; *out_len = 0; if (cbs->len == 0) @@ -85,9 +83,7 @@ CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) int CBS_strdup(const CBS *cbs, char **out_ptr) { - if (*out_ptr != NULL) - free(*out_ptr); - + free(*out_ptr); *out_ptr = strndup((const char*)cbs->data, cbs->len); return (*out_ptr != NULL); }