diff options
author | Ingo Klöcker <[email protected]> | 2025-04-11 08:28:20 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-04-11 08:28:20 +0000 |
commit | 64bb704a25ea1384666d5f0d5202363f4271d948 (patch) | |
tree | 3b5dbf397b5bf949eaf318815092e28446631fd5 | |
parent | cpp: Ensure that all transitions go from one state to a different state (diff) | |
download | gpgme-64bb704a25ea1384666d5f0d5202363f4271d948.tar.gz gpgme-64bb704a25ea1384666d5f0d5202363f4271d948.zip |
cpp: Validate the transition map
* lang/cpp/src/gpgsignkeyeditinteractor.cpp (makeTable): Assert that
all transitions go from one state to a different state.
--
The state machine gets stuck if a transition doesn't change the state.
Make sure that this cannot happen again by mistake.
GnuPG-bug-id: 7600
Taken from gpgmepp commit 6f2e91d4d25afa6934ceaf1563a4d826a904d644
-rw-r--r-- | lang/cpp/src/gpgsignkeyeditinteractor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lang/cpp/src/gpgsignkeyeditinteractor.cpp b/lang/cpp/src/gpgsignkeyeditinteractor.cpp index f2e0ba04..b1ecad3b 100644 --- a/lang/cpp/src/gpgsignkeyeditinteractor.cpp +++ b/lang/cpp/src/gpgsignkeyeditinteractor.cpp @@ -239,6 +239,10 @@ static GpgSignKeyEditInteractor_Private::TransitionMap makeTable() addEntry(ERROR, GET_LINE, "keyedit.prompt", QUIT); addEntry(QUIT, GET_BOOL, "keyedit.save.okay", SAVE); #undef addEntry + // validate the transition map; there must not be a transition without state change + for (auto it = tab.cbegin(); it != tab.cend(); ++it) { + assert(std::get<0>(it->first) != it->second); + } return tab; } |