Skip to contentSkip to conversation

setfont: explicitly initialize ptr to NULL

PATCH Applied Krdyan Areg 2 participants 2 messages Feb 12 – Feb 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 setfont: explicitly initialize ptr to NULL

Variable 'ptr' is declared but not initialized. If an error occurs before the first loop iteration, the error path at 'end' label calls free(ptr) on an uninitialized pointer.

---
 src/libkfont/setfont.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/libkfont/setfont.c +1 -1
index 45652c0..06dc425 100644
@@ -281,7 +281,7 @@ kfont_load_fonts(struct kfont_context *ctx,
 	unsigned char *inbuf, *fontbuf, *bigfontbuf;
 	unsigned int inputlth, fontbuflth, fontsize, height, width;
 	unsigned int bigfontbuflth, bigfontsize, bigheight, bigwidth;
-	unsigned char *ptr;
+	unsigned char *ptr = NULL;
 	struct unicode_list *uclistheads;
 	struct kbdfile *fp = NULL;
 	int i;
Signature · 1 line
2.52.0
#1 lore raw
Quoted 5 lines · Krdyan Areg

Variable 'ptr' is declared but not initialized. If an error occurs before the first loop iteration, the error path at 'end' label calls free(ptr) on an uninitialized pointer.

Applied. Thanks!

Quoted 21 lines
---
 src/libkfont/setfont.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/libkfont/setfont.c +1 -1
index 45652c0..06dc425 100644
@@ -281,7 +281,7 @@ kfont_load_fonts(struct kfont_context *ctx,
 	unsigned char *inbuf, *fontbuf, *bigfontbuf;
 	unsigned int inputlth, fontbuflth, fontsize, height, width;
 	unsigned int bigfontbuflth, bigfontsize, bigheight, bigwidth;
-	unsigned char *ptr;
+	unsigned char *ptr = NULL;
 	struct unicode_list *uclistheads;
 	struct kbdfile *fp = NULL;
 	int i;
Signature · 1 line
2.52.0
Signature · 1 line
Rgrds, legion