fix 2 uninitialized variables and bin == NULL check
This commit is contained in:
		
							
								
								
									
										2
									
								
								drw.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								drw.c
									
									
									
									
									
								
							| @ -228,7 +228,7 @@ int | |||||||
| drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) { | drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) { | ||||||
| 	char buf[1024]; | 	char buf[1024]; | ||||||
| 	int tx, ty, th; | 	int tx, ty, th; | ||||||
| 	unsigned int ew; | 	unsigned int ew = 0; | ||||||
| 	Colormap cmap; | 	Colormap cmap; | ||||||
| 	Visual *vis; | 	Visual *vis; | ||||||
| 	XftDraw *d; | 	XftDraw *d; | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								sent.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								sent.c
									
									
									
									
									
								
							| @ -162,23 +162,25 @@ filter(int fd, const char *cmd) | |||||||
| Image *ffopen(char *filename) | Image *ffopen(char *filename) | ||||||
| { | { | ||||||
| 	unsigned char hdr[16]; | 	unsigned char hdr[16]; | ||||||
| 	char *bin; | 	char *bin = NULL; | ||||||
| 	regex_t regex; | 	regex_t regex; | ||||||
| 	Image *img; | 	Image *img; | ||||||
| 	size_t i; | 	size_t i; | ||||||
| 	int tmpfd, fd; | 	int tmpfd, fd; | ||||||
|  |  | ||||||
| 	for (bin = NULL, i = 0; i < LEN(filters); i++) { | 	for (i = 0; i < LEN(filters); i++) { | ||||||
| 		if (regcomp(®ex, filters[i].regex, | 		if (regcomp(®ex, filters[i].regex, | ||||||
| 		            REG_NOSUB | REG_EXTENDED | REG_ICASE)) | 		            REG_NOSUB | REG_EXTENDED | REG_ICASE)) | ||||||
| 			continue; | 			continue; | ||||||
| 		if (!regexec(®ex, filename, 0, NULL, 0)) { | 		if (!regexec(®ex, filename, 0, NULL, 0)) { | ||||||
| 			if (!(bin = filters[i].bin)) | 			bin = filters[i].bin | ||||||
| 				return NULL; |  | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (!bin) | ||||||
|  | 		return NULL; | ||||||
|  |  | ||||||
| 	if ((fd = open(filename, O_RDONLY)) < 0) { | 	if ((fd = open(filename, O_RDONLY)) < 0) { | ||||||
| 		eprintf("Unable to open file %s:", filename); | 		eprintf("Unable to open file %s:", filename); | ||||||
| 		return NULL; | 		return NULL; | ||||||
| @ -355,7 +357,7 @@ void ffdraw(Image *img) | |||||||
| void getfontsize(Slide *s, unsigned int *width, unsigned int *height) | void getfontsize(Slide *s, unsigned int *width, unsigned int *height) | ||||||
| { | { | ||||||
| 	int i, j; | 	int i, j; | ||||||
| 	unsigned int curw, imax; | 	unsigned int curw, new_max; | ||||||
| 	float lfac = linespacing * (s->linecount - 1) + 1; | 	float lfac = linespacing * (s->linecount - 1) + 1; | ||||||
|  |  | ||||||
| 	/* fit height */ | 	/* fit height */ | ||||||
| @ -369,13 +371,12 @@ void getfontsize(Slide *s, unsigned int *width, unsigned int *height) | |||||||
| 	*width = 0; | 	*width = 0; | ||||||
| 	for (i = 0; i < s->linecount; i++) { | 	for (i = 0; i < s->linecount; i++) { | ||||||
| 		curw = drw_fontset_getwidth(d, s->lines[i]); | 		curw = drw_fontset_getwidth(d, s->lines[i]); | ||||||
| 		if (curw >= *width) | 		newmax = (curw >= *width); | ||||||
| 			imax = i; |  | ||||||
| 		while (j > 0 && curw > xw.uw) { | 		while (j > 0 && curw > xw.uw) { | ||||||
| 			drw_setfontset(d, fonts[--j]); | 			drw_setfontset(d, fonts[--j]); | ||||||
| 			curw = drw_fontset_getwidth(d, s->lines[i]); | 			curw = drw_fontset_getwidth(d, s->lines[i]); | ||||||
| 		} | 		} | ||||||
| 		if (imax == i) | 		if (newmax) | ||||||
| 			*width = curw; | 			*width = curw; | ||||||
| 	} | 	} | ||||||
| 	*height = fonts[j]->h * lfac; | 	*height = fonts[j]->h * lfac; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user