external/boringssl: cherry-pick crash fix am: 9083ef933c am: df7c2ebfda
am: b25d4789fb
Change-Id: I4662ace073a90a679d35c1737396fd56ccfdf952
diff --git a/src/crypto/fipsmodule/ec/ec.c b/src/crypto/fipsmodule/ec/ec.c
index 616df16..e45a7e3 100644
--- a/src/crypto/fipsmodule/ec/ec.c
+++ b/src/crypto/fipsmodule/ec/ec.c
@@ -768,7 +768,13 @@
if (!EC_POINT_is_on_curve(group, point, ctx)) {
// In the event of an error, defend against the caller not checking the
// return value by setting a known safe value: the base point.
- EC_POINT_copy(point, EC_GROUP_get0_generator(group));
+ const EC_POINT *generator = EC_GROUP_get0_generator(group);
+ // The generator can be missing if the caller is in the process of
+ // constructing an arbitrary group. In this, we give up and hope they're
+ // checking the return value.
+ if (generator) {
+ EC_POINT_copy(point, generator);
+ }
OPENSSL_PUT_ERROR(EC, EC_R_POINT_IS_NOT_ON_CURVE);
return 0;
}