linux-user: Protect against allocation failure in load_symbols.
Cc: malc <av1474@comtv.ru> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
		
							parent
							
								
									58f5c1eb89
								
							
						
					
					
						commit
						5d5c99300d
					
				@ -1546,7 +1546,17 @@ static void load_symbols(struct elfhdr *hdr, int fd, abi_ulong load_bias)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Attempt to free the storage associated with the local symbols
 | 
				
			||||||
 | 
					       that we threw away.  Whether or not this has any effect on the
 | 
				
			||||||
 | 
					       memory allocation depends on the malloc implementation and how
 | 
				
			||||||
 | 
					       many symbols we managed to discard.  */
 | 
				
			||||||
    syms = realloc(syms, nsyms * sizeof(*syms));
 | 
					    syms = realloc(syms, nsyms * sizeof(*syms));
 | 
				
			||||||
 | 
					    if (syms == NULL) {
 | 
				
			||||||
 | 
					        free(s);
 | 
				
			||||||
 | 
					        free(strings);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qsort(syms, nsyms, sizeof(*syms), symcmp);
 | 
					    qsort(syms, nsyms, sizeof(*syms), symcmp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->disas_num_syms = nsyms;
 | 
					    s->disas_num_syms = nsyms;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user