acegoal07 2 лет назад
Родитель
Сommit
9699914d1c
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      scences/emulation.c

+ 9 - 6
scences/emulation.c

@@ -95,8 +95,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
             int time_counter_ms = (options_emulate_timeout[nfc_playlist->emulate_timeout]*1000);
 
             if (storage_file_exists(storage, file_path) == false) {
-                char popup_header_text[(18 + strlen(file_name))];
-                snprintf(popup_header_text, (18 + strlen(file_name)), "%s\n%s", "ERROR not found:", file_name);
+                int popup_header_text_size = strlen(file_name) + 18;
+                char popup_header_text[popup_header_text_size];
+                snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR not found:", file_name);
                 popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
                 start_blink(nfc_playlist, NfcPlaylistLedState_Error);
                 while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
@@ -109,8 +110,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
             }
 
             else if (strcasestr(file_ext, "nfc") == NULL) {
-                char popup_header_text[(21 + strlen(file_name))];
-                snprintf(popup_header_text, (21 + strlen(file_name)), "%s\n%s", "ERROR invalid file:", file_name);
+                int popup_header_text_size = strlen(file_name) + 21;
+                char popup_header_text[popup_header_text_size];
+                snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR invalid file:", file_name);
                 popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
                 start_blink(nfc_playlist, NfcPlaylistLedState_Error);
                 while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
@@ -123,8 +125,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
             }
 
             else {
-                char popup_header_text[(12 + strlen(file_name))];
-                snprintf(popup_header_text, (12 + strlen(file_name)), "%s\n%s", "Emulating:", file_name);
+                int popup_header_text_size = strlen(file_name) + 12;
+                char popup_header_text[popup_header_text_size];
+                snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "Emulating:", file_name);
                 popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
                 nfc_playlist_worker_set_nfc_data(nfc_playlist->nfc_playlist_worker, file_path);
                 nfc_playlist_worker_start(nfc_playlist->nfc_playlist_worker);