summaryrefslogtreecommitdiff
path: root/src/smi_video.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-15 09:13:22 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-15 09:13:22 -0800
commit343b595d28a2808f08c99faabbde2d999e43b5e7 (patch)
tree51df76c725dd1ff260eb3d7be37b45f9852461c2 /src/smi_video.c
parent8cddfb1205dd000e5071c237fbbda84656149242 (diff)
Replace malloc()+snprintf() with Xasprintf()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/smi_video.c')
-rw-r--r--src/smi_video.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/smi_video.c b/src/smi_video.c
index 6266011..055f606 100644
--- a/src/smi_video.c
+++ b/src/smi_video.c
@@ -518,14 +518,18 @@ SMI_AddEncoding(XF86VideoEncodingPtr enc, int i,
norm_string = VideoNorms[norm].name;
input_string = VideoInputs[input].name;
- sprintf(channel_string, "%d", channel);
+ snprintf(channel_string, sizeof(channel_string), "%d", channel);
enc[i].id = i;
- name_string = malloc(strlen(norm_string) +
- strlen(input_string) +
- strlen(channel_string)+3);
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+ if (Xasprintf(&name_string, "%s-%s-%s",
+ norm_string, input_string, channel_string) < 0)
+ LEAVE(-1);
+#else
+ name_string = Xprintf("%s-%s-%s",
+ norm_string, input_string, channel_string);
if (NULL == name_string)
LEAVE(-1);
- sprintf(name_string,"%s-%s-%s", norm_string, input_string, channel_string);
+#endif
enc[i].name = name_string;
enc[i].width = VideoNorms[norm].Wa;