Init all sample pointers when reusing loan
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									9cf4b97f1a
								
							
						
					
					
						commit
						9b1920862e
					
				
					 3 changed files with 6 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -84,7 +84,10 @@ static dds_return_t dds_read_impl (bool take, dds_entity_t reader_or_condition,
 | 
			
		|||
      if (rd->m_loan)
 | 
			
		||||
      {
 | 
			
		||||
        if (rd->m_loan_size >= maxs)
 | 
			
		||||
          buf[0] = rd->m_loan;
 | 
			
		||||
        {
 | 
			
		||||
          /* This ensures buf is properly initialized */
 | 
			
		||||
          ddsi_sertopic_realloc_samples (buf, rd->m_topic->m_stopic, rd->m_loan, rd->m_loan_size, rd->m_loan_size);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          ddsi_sertopic_realloc_samples (buf, rd->m_topic->m_stopic, rd->m_loan, rd->m_loan_size, maxs);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ static void sertopic_builtin_realloc_samples (void **ptrs, const struct ddsi_ser
 | 
			
		|||
{
 | 
			
		||||
  const struct ddsi_sertopic_builtintopic *tp = (const struct ddsi_sertopic_builtintopic *)sertopic_common;
 | 
			
		||||
  const size_t size = get_size (tp->type);
 | 
			
		||||
  char *new = dds_realloc (old, size * count);
 | 
			
		||||
  char *new = (oldcount == count) ? old : dds_realloc (old, size * count);
 | 
			
		||||
  if (new && count > oldcount)
 | 
			
		||||
    memset (new + size * oldcount, 0, size * (count - oldcount));
 | 
			
		||||
  for (size_t i = 0; i < count; i++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ static void sertopic_default_realloc_samples (void **ptrs, const struct ddsi_ser
 | 
			
		|||
{
 | 
			
		||||
  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
			
		||||
  const size_t size = tp->type->m_size;
 | 
			
		||||
  char *new = dds_realloc (old, size * count);
 | 
			
		||||
  char *new = (oldcount == count) ? old : dds_realloc (old, size * count);
 | 
			
		||||
  if (new && count > oldcount)
 | 
			
		||||
    memset (new + size * oldcount, 0, size * (count - oldcount));
 | 
			
		||||
  for (size_t i = 0; i < count; i++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue