Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false-positive compiler warning #3857

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,8 @@ static int cs2cs_emulation_setup(PJ *P) {
/* We ignore helmert if we have grid shift */
p = P->hgridshift ? nullptr : pj_param_exists(P->params, "towgs84");
while (p) {
char *def;
char *s = p->param;
double *d = P->datum_params;
size_t n = strlen(s);
const char *const s = p->param;
const double *const d = P->datum_params;

/* We ignore null helmert shifts (common in auto-translated resource
* files, e.g. epsg) */
Expand All @@ -938,19 +936,17 @@ static int cs2cs_emulation_setup(PJ *P) {
break;
}

const size_t n = strlen(s);
if (n <= 8) /* 8==strlen ("towgs84=") */
return 0;

size_t def_size = 100 + n;
def = static_cast<char *>(malloc(def_size));
if (nullptr == def)
return 0;
snprintf(def, def_size,
"break_cs2cs_recursion proj=helmert exact %s "
"convention=position_vector",
s);
Q = pj_create_internal(P->ctx, def);
free(def);
const size_t def_max_size = 100 + n;
std::string def;
def.reserve(def_max_size);
def += "break_cs2cs_recursion proj=helmert exact ";
def += s;
def += " convention=position_vector";
Q = pj_create_internal(P->ctx, def.c_str());
if (nullptr == Q)
return 0;
pj_inherit_ellipsoid_def(P, Q);
Expand Down
Loading