if a malloc fails, clear up the memory and return failure
This commit is contained in:
		
							
								
								
									
										10
									
								
								lib/cookie.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								lib/cookie.c
									
									
									
									
									
								
							@@ -705,6 +705,16 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
 | 
				
			|||||||
             /* point the main to us */
 | 
					             /* point the main to us */
 | 
				
			||||||
             mainco = newco;
 | 
					             mainco = newco;
 | 
				
			||||||
           }
 | 
					           }
 | 
				
			||||||
 | 
					           else {
 | 
				
			||||||
 | 
					              /* failure, clear up the allocated chain and return NULL */
 | 
				
			||||||
 | 
					             while(mainco) {
 | 
				
			||||||
 | 
					               co = mainco->next;
 | 
				
			||||||
 | 
					               free(mainco);
 | 
				
			||||||
 | 
					               mainco = co;
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					             return NULL;
 | 
				
			||||||
 | 
					           }
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user