Просмотр исходного кода

Manually merge PR #57 by @GeorgeBotsev + free string (malloc'd by strdup)

0xchocolate 1 год назад
Родитель
Сommit
55193e7f4e
1 измененных файлов с 10 добавлено и 8 удалено
  1. 10 8
      scenes/wifi_marauder_scene_console_output.c

+ 10 - 8
scenes/wifi_marauder_scene_console_output.c

@@ -131,15 +131,17 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
         // Create files *before* sending command
         // (it takes time to iterate through the directory)
         if(app->ok_to_save_logs) {
-            strcpy(
-                app->log_file_path,
-                sequential_file_resolve_path(
-                    app->storage, MARAUDER_APP_FOLDER_LOGS, prefix, "log"));
-            if(storage_file_open(
-                   app->log_file, app->log_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
-                app->is_writing_log = true;
+	    char* resolved_path = sequential_file_resolve_path(app->storage, MARAUDER_APP_FOLDER_LOGS, prefix, "log");
+            if(resolved_path != NULL) {
+                strcpy(app->log_file_path, resolved_path);
+		free(resolved_path);
+                if(storage_file_open(app->log_file, app->log_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
+		  app->is_writing_log = true;
+		} else {
+		    dialog_message_show_storage_error(app->dialogs, "Cannot open log file");
+		}
             } else {
-                dialog_message_show_storage_error(app->dialogs, "Cannot open log file");
+                dialog_message_show_storage_error(app->dialogs, "Cannot resolve log path");
             }
         }