Correct sign comparison error with sk_X509_OBJECT_num (#2355)

* Correct sign comparison error with sk_X509_OBJECT_num

In some build configurations, sk_X509_OBJECT_num (from BoringSSL) returns a size_t. Comparing this directly against a signed int loop counter triggers -Werror,-Wsign-compare.

Instead, move the count into a local int variable so the compiler uses implicit conversion to ensure type consistency during the loop comparison.

* Update httplib.h

* Update httplib.h

Missed a s/int/decltype(count)
This commit is contained in:
Justin
2026-02-11 07:54:35 -10:00
committed by GitHub
parent f69737a838
commit 77d945d3b6
+8 -6
View File
@@ -14743,7 +14743,8 @@ inline std::string x509_store_to_pem(X509_STORE *store) {
std::string pem;
auto objs = X509_STORE_get0_objects(store);
if (!objs) return {};
for (int i = 0; i < sk_X509_OBJECT_num(objs); i++) {
auto count = sk_X509_OBJECT_num(objs);
for (decltype(count) i = 0; i < count; i++) {
auto obj = sk_X509_OBJECT_value(objs, i);
if (X509_OBJECT_get_type(obj) == X509_LU_X509) {
auto cert = X509_OBJECT_get0_X509(obj);
@@ -14810,7 +14811,8 @@ inline STACK_OF(X509_NAME) *
return nullptr;
}
for (int i = 0; i < sk_X509_OBJECT_num(objs); i++) {
auto count = sk_X509_OBJECT_num(objs);
for (decltype(count) i = 0; i < count; i++) {
auto obj = sk_X509_OBJECT_value(objs, i);
if (X509_OBJECT_get_type(obj) == X509_LU_X509) {
auto cert = X509_OBJECT_get0_X509(obj);
@@ -15570,8 +15572,8 @@ inline size_t get_ca_certs(ctx_t ctx, std::vector<cert_t> &certs) {
auto objs = X509_STORE_get0_objects(store);
if (!objs) { return 0; }
int count = sk_X509_OBJECT_num(objs);
for (int i = 0; i < count; i++) {
auto count = sk_X509_OBJECT_num(objs);
for (decltype(count) i = 0; i < count; i++) {
auto obj = sk_X509_OBJECT_value(objs, i);
if (!obj) { continue; }
if (X509_OBJECT_get_type(obj) == X509_LU_X509) {
@@ -15597,8 +15599,8 @@ inline std::vector<std::string> get_ca_names(ctx_t ctx) {
auto objs = X509_STORE_get0_objects(store);
if (!objs) { return names; }
int count = sk_X509_OBJECT_num(objs);
for (int i = 0; i < count; i++) {
auto count = sk_X509_OBJECT_num(objs);
for (decltype(count) i = 0; i < count; i++) {
auto obj = sk_X509_OBJECT_value(objs, i);
if (!obj) { continue; }
if (X509_OBJECT_get_type(obj) == X509_LU_X509) {