Skip to content

Commit 9699914

Browse files
committed
Update emulation.c
1 parent 28c4893 commit 9699914

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scences/emulation.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
9595
int time_counter_ms = (options_emulate_timeout[nfc_playlist->emulate_timeout]*1000);
9696

9797
if (storage_file_exists(storage, file_path) == false) {
98-
char popup_header_text[(18 + strlen(file_name))];
99-
snprintf(popup_header_text, (18 + strlen(file_name)), "%s\n%s", "ERROR not found:", file_name);
98+
int popup_header_text_size = strlen(file_name) + 18;
99+
char popup_header_text[popup_header_text_size];
100+
snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR not found:", file_name);
100101
popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
101102
start_blink(nfc_playlist, NfcPlaylistLedState_Error);
102103
while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
@@ -109,8 +110,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
109110
}
110111

111112
else if (strcasestr(file_ext, "nfc") == NULL) {
112-
char popup_header_text[(21 + strlen(file_name))];
113-
snprintf(popup_header_text, (21 + strlen(file_name)), "%s\n%s", "ERROR invalid file:", file_name);
113+
int popup_header_text_size = strlen(file_name) + 21;
114+
char popup_header_text[popup_header_text_size];
115+
snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR invalid file:", file_name);
114116
popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
115117
start_blink(nfc_playlist, NfcPlaylistLedState_Error);
116118
while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
@@ -123,8 +125,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
123125
}
124126

125127
else {
126-
char popup_header_text[(12 + strlen(file_name))];
127-
snprintf(popup_header_text, (12 + strlen(file_name)), "%s\n%s", "Emulating:", file_name);
128+
int popup_header_text_size = strlen(file_name) + 12;
129+
char popup_header_text[popup_header_text_size];
130+
snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "Emulating:", file_name);
128131
popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
129132
nfc_playlist_worker_set_nfc_data(nfc_playlist->nfc_playlist_worker, file_path);
130133
nfc_playlist_worker_start(nfc_playlist->nfc_playlist_worker);

0 commit comments

Comments
 (0)