Check if pointers are null before calling memset (#290)
This commit is contained in:
		
							parent
							
								
									ceff88b974
								
							
						
					
					
						commit
						955c0c93da
					
				
					 1 changed files with 15 additions and 11 deletions
				
			
		| 
						 | 
					@ -211,21 +211,25 @@ rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * al
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SET_CLEAR(Type) \
 | 
					#define SET_CLEAR(Type) \
 | 
				
			||||||
  do { \
 | 
					  do { \
 | 
				
			||||||
 | 
					    if (NULL != wait_set->Type ## s) { \
 | 
				
			||||||
      memset( \
 | 
					      memset( \
 | 
				
			||||||
        (void *)wait_set->Type ## s, \
 | 
					        (void *)wait_set->Type ## s, \
 | 
				
			||||||
        0, \
 | 
					        0, \
 | 
				
			||||||
        sizeof(rcl_ ## Type ## _t *) * wait_set->size_of_ ## Type ## s); \
 | 
					        sizeof(rcl_ ## Type ## _t *) * wait_set->size_of_ ## Type ## s); \
 | 
				
			||||||
      wait_set->impl->Type ## _index = 0; \
 | 
					      wait_set->impl->Type ## _index = 0; \
 | 
				
			||||||
 | 
					    } \
 | 
				
			||||||
  } while (false)
 | 
					  } while (false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SET_CLEAR_RMW(Type, RMWStorage, RMWCount) \
 | 
					#define SET_CLEAR_RMW(Type, RMWStorage, RMWCount) \
 | 
				
			||||||
  do { \
 | 
					  do { \
 | 
				
			||||||
 | 
					    if (NULL != wait_set->impl->RMWStorage) { \
 | 
				
			||||||
      /* Also clear the rmw storage. */ \
 | 
					      /* Also clear the rmw storage. */ \
 | 
				
			||||||
      memset( \
 | 
					      memset( \
 | 
				
			||||||
        wait_set->impl->RMWStorage, \
 | 
					        wait_set->impl->RMWStorage, \
 | 
				
			||||||
        0, \
 | 
					        0, \
 | 
				
			||||||
        sizeof(void *) * wait_set->impl->RMWCount); \
 | 
					        sizeof(void *) * wait_set->impl->RMWCount); \
 | 
				
			||||||
      wait_set->impl->RMWCount = 0; \
 | 
					      wait_set->impl->RMWCount = 0; \
 | 
				
			||||||
 | 
					    } \
 | 
				
			||||||
  } while (false)
 | 
					  } while (false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SET_RESIZE(Type, ExtraDealloc, ExtraRealloc) \
 | 
					#define SET_RESIZE(Type, ExtraDealloc, ExtraRealloc) \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue