Add error handling. Check return value of ParseUInt32(...) in ParseHDKeypath(...).
ParseUInt32(...) returns false if the entire string could not be parsed or when an overflow or underflow occurred. In such case the uninitialized variable number would be used in the calculation of path (prior to this commit).
An example key path triggering this is m/0/4294967296:
0 ParseHDKeypath("m/0/4294967296", keypath);
4294967296 is 1 + 0xFFFFFFFF (uint32_t max: 4294967295).
Introduced in a4b06fb42eb0ad94e562ca839391b57e69285136 which was merged into master 14 hours ago as part of #13557 (“BIP 174 PSBT Serializations and RPCs”).