mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Replace &vec[0] with vec.data()
				
					
				
			When the vector is empty, using `&vec[0]` involves undefined behaviour. While that works fine most of the time, Flatpak builds aborted on a failed `__builtin_expect`. I searched for such occurences across the codebase with the regex `(?<!&)&\w+\[0\]` and fixed those that would potentially cause issues.
This commit is contained in:
		
							parent
							
								
									5241032fc5
								
							
						
					
					
						commit
						f85bde3ca3
					
				
					 3 changed files with 7 additions and 6 deletions
				
			
		|  | @ -554,15 +554,16 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect | |||
|                 // Decompress .code section...
 | ||||
|                 u32 decompressed_size = LZSS_GetDecompressedSize(&temp_buffer[0], section.size); | ||||
|                 buffer.resize(decompressed_size); | ||||
|                 if (!LZSS_Decompress(&temp_buffer[0], section.size, &buffer[0], decompressed_size)) | ||||
|                 if (!LZSS_Decompress(&temp_buffer[0], section.size, buffer.data(), | ||||
|                                      decompressed_size)) | ||||
|                     return Loader::ResultStatus::ErrorInvalidFormat; | ||||
|             } else { | ||||
|                 // Section is uncompressed...
 | ||||
|                 buffer.resize(section.size); | ||||
|                 if (exefs_file.ReadBytes(&buffer[0], section.size) != section.size) | ||||
|                 if (exefs_file.ReadBytes(buffer.data(), section.size) != section.size) | ||||
|                     return Loader::ResultStatus::Error; | ||||
|                 if (is_encrypted) { | ||||
|                     dec.ProcessData(&buffer[0], &buffer[0], section.size); | ||||
|                     dec.ProcessData(buffer.data(), buffer.data(), section.size); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|  | @ -641,7 +642,7 @@ Loader::ResultStatus NCCHContainer::LoadOverrideExeFSSection(const char* name, | |||
|             buffer.resize(section_size); | ||||
| 
 | ||||
|             section_file.Seek(0, SEEK_SET); | ||||
|             if (section_file.ReadBytes(&buffer[0], section_size) == section_size) { | ||||
|             if (section_file.ReadBytes(buffer.data(), section_size) == section_size) { | ||||
|                 LOG_WARNING(Service_FS, "File {} overriding built-in ExeFS file", path); | ||||
|                 return Loader::ResultStatus::Success; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue