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

Throw on invalid characters when decoding geohash #420

Closed
wants to merge 2 commits into from

Conversation

@Algunenano
Copy link
Member

commented Jun 13, 2019

@strk strk closed this in c340270 Jun 13, 2019

@mentin
Copy link

left a comment

I think rather than duplicate knowledge of valid base32 characters, it is much cleaner to just check the result of strchr:
char* p = strchr(base32, c);
if (!p) { lwerror(...); return; }
cd = p - base32;

@Algunenano

This comment has been minimized.

Copy link
Member Author

commented Jun 14, 2019

I think rather than duplicate knowledge of valid base32 characters, it is much cleaner to just check the result of strchr:
char* p = strchr(base32, c);
if (!p) { lwerror(...); return; }
cd = p - base32;

Makes sense. It's slower but, as you say, much cleaner. I'll change it.

Algunenano added a commit to Algunenano/postgis that referenced this pull request Jun 14, 2019
Throw on invalid characters when decoding geohash
Closes #4406
Closes postgis#420

git-svn-id: http://svn.osgeo.org/postgis/trunk@17529 b70326c6-7e19-0410-871a-916f4a2858ee
@mentin

This comment has been minimized.

Copy link

commented Jun 14, 2019

Should not be slower - since the function is calling strchr() anyway.
Just before using its result it should check whether strchr() returned NULL.
So there should still be only one strchr() call per character, as in original,
and just a single new condition checking whether it returned NULL.

@Algunenano

This comment has been minimized.

Copy link
Member Author

commented Jun 14, 2019

Changed in 221bbd9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.