public inbox for kbd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] setfont: explicitly initialize ptr to NULL
@ 2026-02-12 14:13 Krdyan Areg
  2026-02-13 10:33 ` Alexey Gladkov
  0 siblings, 1 reply; 2+ messages in thread
From: Krdyan Areg @ 2026-02-12 14:13 UTC (permalink / raw)
  To: kbd; +Cc: 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.

Signed-off-by: Krdyan Areg <areg.krdian@gmail.com>
---
 src/libkfont/setfont.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libkfont/setfont.c b/src/libkfont/setfont.c
index 45652c0..06dc425 100644
--- a/src/libkfont/setfont.c
+++ b/src/libkfont/setfont.c
@@ -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;
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] setfont: explicitly initialize ptr to NULL
  2026-02-12 14:13 [PATCH] setfont: explicitly initialize ptr to NULL Krdyan Areg
@ 2026-02-13 10:33 ` Alexey Gladkov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexey Gladkov @ 2026-02-13 10:33 UTC (permalink / raw)
  To: Krdyan Areg; +Cc: kbd

On Thu, Feb 12, 2026 at 05:13:39PM +0300, Krdyan Areg wrote:
> 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.
> 
> Signed-off-by: Krdyan Areg <areg.krdian@gmail.com>

Applied. Thanks!

> ---
>  src/libkfont/setfont.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libkfont/setfont.c b/src/libkfont/setfont.c
> index 45652c0..06dc425 100644
> --- a/src/libkfont/setfont.c
> +++ b/src/libkfont/setfont.c
> @@ -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;
> -- 
> 2.52.0
> 
> 

-- 
Rgrds, legion


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-13 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 14:13 [PATCH] setfont: explicitly initialize ptr to NULL Krdyan Areg
2026-02-13 10:33 ` Alexey Gladkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox