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 second potential use of uninitialized value in cellToVertex #690

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/apps/testapps/testVertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ SUITE(Vertex) {
"Invalid cell returns error");
}

TEST(cellToVertex_invalid3) {
H3Index index = 0x20ff20202020ff35;
H3Index vert;
t_assert(H3_EXPORT(cellToVertex)(index, 0, &vert) == E_CELL_INVALID,
"Invalid cell returns error");
}

TEST(isValidVertex_hex) {
H3Index origin = 0x823d6ffffffffff;
H3Index vert = 0x2222597fffffffff;
Expand Down
4 changes: 3 additions & 1 deletion src/h3lib/lib/vertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ H3Error H3_EXPORT(cellToVertex)(H3Index cell, int vertexNum, H3Index *out) {
if (right == INVALID_DIGIT) return E_FAILED; // LCOV_EXCL_LINE
int rRotations = 0;
H3Index rightNeighbor;
h3NeighborRotations(cell, right, &rRotations, &rightNeighbor);
H3Error rightNeighborError =
h3NeighborRotations(cell, right, &rRotations, &rightNeighbor);
if (rightNeighborError) return rightNeighborError;
// Set to owner if lowest index
if (rightNeighbor < owner) {
owner = rightNeighbor;
Expand Down