Selaa lähdekoodia

Fix build against LLVM CFI.

The first line of bssl::New is invalid in LLVM CFI as we are casting a
pointer to T before the object is constructed. Instead, we should leave
it as void* and only use it as a T* afterward being constructed.

Bug: chromium:750445
Change-Id: I0ae60c2a7e541b45bc0155dd8f359b662f561dcc
Reviewed-on: https://boringssl-review.googlesource.com/18684
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
kris/onging/CECPQ3_patch15
David Benjamin 7 vuotta sitten
committed by CQ bot account: commit-bot@chromium.org
vanhempi
commit
a4cb62f0ae
1 muutettua tiedostoa jossa 2 lisäystä ja 3 poistoa
  1. +2
    -3
      ssl/internal.h

+ 2
- 3
ssl/internal.h Näytä tiedosto

@@ -181,13 +181,12 @@ struct SSL_HANDSHAKE;
* Note: unlike |new|, this does not support non-public constructors. */
template <typename T, typename... Args>
T *New(Args &&... args) {
T *t = reinterpret_cast<T *>(OPENSSL_malloc(sizeof(T)));
void *t = OPENSSL_malloc(sizeof(T));
if (t == nullptr) {
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
return nullptr;
}
new (t) T(std::forward<Args>(args)...);
return t;
return new (t) T(std::forward<Args>(args)...);
}

/* Delete behaves like |delete| but uses |OPENSSL_free| to release memory.


Ladataan…
Peruuta
Tallenna