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

Fixed null pointer on beacon list stage

tcpassos 2 лет назад
Родитель
Сommit
b01b0988c1

+ 4 - 2
applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_script_edit_list.c

@@ -47,14 +47,16 @@ static void wifi_marauder_scene_script_stage_edit_list_save_strings(WifiMarauder
 
     // Reallocate the array of strings if necessary
     if (*app->script_stage_edit_string_count_reference < array_size) {
-        *app->script_stage_edit_strings_reference = realloc(*app->script_stage_edit_strings_reference, array_size);
+        *app->script_stage_edit_strings_reference = realloc(*app->script_stage_edit_strings_reference, array_size * sizeof(char*));
     }
 
     // Fills the array of strings
     current_item = app->script_stage_edit_first_item;
     int i = 0;
     while (current_item != NULL) {
-        strncpy((*app->script_stage_edit_strings_reference)[i], current_item->value, strlen(current_item->value) + 1);
+        char* current_str = malloc(strlen(current_item->value) + 1);
+        strncpy(current_str, current_item->value, strlen(current_item->value) + 1);
+        (*app->script_stage_edit_strings_reference)[i] = current_str;
         current_item = current_item->next_item;
         i++;
     }