Skip to content

Commit ba3215b

Browse files
author
Marcel Hecko
committed
Fix callback crash when playing back entered digits (issue #180)
The callback application crashed with a kernel trap when users entered digits followed by * or #. The bug was caused by undefined behavior: creating an empty string and writing to index 0. Fixed by properly converting character digits to strings using int2str(), which matches how prompts are registered. Also added debug logging to help troubleshoot digit playback. This fixes the issue where SEMS would restart after playing back the entered number.
1 parent 6e113db commit ba3215b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/callback/CallBack.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,14 @@ void CallBackDialog::onDtmf(int event, int duration)
280280
} else {
281281
state = CBTellingNumber;
282282
play_list.flush();
283+
DBG("playing back entered number '%s' (length: %zu)\n",
284+
call_number.c_str(), call_number.length());
283285
for (size_t i=0;i<call_number.length();i++) {
284-
string num = "";
285-
num[0] = call_number[i]; // this works?
286-
DBG("adding '%s' to playlist.\n", num.c_str());
286+
// Convert character digit to integer, then to string to match prompt key
287+
int digit = call_number[i] - '0';
288+
string num = int2str(digit);
289+
DBG("adding digit prompt '%s' (from char '%c', digit %d) to playlist.\n",
290+
num.c_str(), call_number[i], digit);
287291
prompts.addToPlaylist(num,
288292
(long)this, play_list);
289293
}

0 commit comments

Comments
 (0)