mirror of
				https://github.com/SwallowOS/xorg_lib_libfontenc
				synced 2025-11-04 13:56:02 +08:00 
			
		
		
		
	libfontenc: setCode(): fix realloc invocation
This patch fixes two bugs in the realloc invocation in setCode(), which most likely cause memory corruption when realloc is triggered: 1. Pass *enc to realloc (which is the dynamically-allocated buffer), instead of enc (which stores a pointer to the dynamically-allocated buffer). 2. Allocate enough memory for (*encsize) shorts, instead of (*encsize) bytes; see the call to malloc just above the realloc call. Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu> Reviewed-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
		
				
					committed by
					
						
						Alan Coopersmith
					
				
			
			
				
	
			
			
			
						parent
						
							f5d1208172
						
					
				
				
					commit
					624508365e
				
			@@ -426,7 +426,7 @@ setCode(unsigned from, unsigned to, unsigned row_size,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if(*encsize <= index) {
 | 
					    } else if(*encsize <= index) {
 | 
				
			||||||
        *encsize = 0x10000;
 | 
					        *encsize = 0x10000;
 | 
				
			||||||
        if((newenc = realloc(enc, *encsize))==NULL)
 | 
					        if((newenc = realloc(*enc, (*encsize) * sizeof(unsigned short)))==NULL)
 | 
				
			||||||
            return 1;
 | 
					            return 1;
 | 
				
			||||||
        *enc = newenc;
 | 
					        *enc = newenc;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user