From 1dee1890e75b9b2426bf30774534f6abf1fede00 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 18:28:04 +0000 Subject: [PATCH] Mask the node state out of the operation when marking shared nodes Geometry that was clipped to --clip-bounding-box while it was being serialized can already have node states in its operation bytes, so the unmasked comparison against VT_MOVETO and VT_LINETO failed to recognize those vertices and lost track of where the following vertices began. Also stop with an error instead of continuing if the operation is not one that can appear in serialized geometry. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01P2nBqZisxNQfmEmon3vE9v --- serial.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serial.cpp b/serial.cpp index 7f9cc70c..cefd1176 100644 --- a/serial.cpp +++ b/serial.cpp @@ -345,6 +345,9 @@ void mark_shared_nodes(char *feature, size_t len, unsigned *initial_x, unsigned return; } + // the vertex may already have a node state, from clipping to --clip-bounding-box + op &= OP_MASK; + if (op == VT_MOVETO || op == VT_LINETO) { long long dx, dy; @@ -356,6 +359,9 @@ void mark_shared_nodes(char *feature, size_t len, unsigned *initial_x, unsigned signed char node = is_shared_node(wx, wy, shared_nodes_map, nodepos, shared_nodes_bloom) ? NODE_SHARED : NODE_NOT_SHARED; *opp = op | (node << NODE_SHIFT); + } else if (op != VT_CLOSEPATH) { + fprintf(stderr, "Internal error: unexpected geometry operation %d marking shared nodes\n", op); + exit(EXIT_IMPOSSIBLE); } }