Skip to content

Commit 226211f

Browse files
committed
glamor: replace XNFasprintf() by asprintf()
Just use standard libc functions instead of own (incomplete) implementations. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
1 parent cd3b208 commit 226211f

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

glamor/glamor_gradient.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ _glamor_create_getcolor_fs_source(ScreenPtr screen, int stops_count,
169169
"}\n";
170170

171171
if (use_array) {
172-
XNFasprintf(&gradient_fs,
173-
gradient_fs_getcolor, stops_count, stops_count);
172+
if (asprintf(&gradient_fs,
173+
gradient_fs_getcolor, stops_count, stops_count) == -1) {
174+
ErrorF("Failed to allocate gradient_fs memory.\n");
175+
return NULL;
176+
}
174177
return gradient_fs;
175178
}
176179
else {
@@ -335,11 +338,12 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
335338
_glamor_create_getcolor_fs_source(screen, stops_count,
336339
(stops_count > 0));
337340

338-
XNFasprintf(&gradient_fs,
341+
if (asprintf(&gradient_fs,
339342
gradient_radial_fs_template,
340343
PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL,
341344
PIXMAN_REPEAT_REFLECT,
342-
fs_getcolor_source);
345+
fs_getcolor_source) == -1)
346+
return FALSE;
343347

344348
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
345349

@@ -522,10 +526,11 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
522526
fs_getcolor_source =
523527
_glamor_create_getcolor_fs_source(screen, stops_count, stops_count > 0);
524528

525-
XNFasprintf(&gradient_fs,
529+
if (asprintf(&gradient_fs,
526530
gradient_fs_template,
527531
PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT,
528-
fs_getcolor_source);
532+
fs_getcolor_source) == -1)
533+
return FALSE;
529534

530535
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
531536
free(gradient_fs);

glamor/glamor_render.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,14 @@ glamor_create_composite_fs(glamor_screen_private *glamor_priv, struct shader_key
335335
FatalError("Bad composite IN type");
336336
}
337337

338-
XNFasprintf(&source,
338+
if (asprintf(&source,
339339
"%s"
340340
GLAMOR_DEFAULT_PRECISION
341341
"%s%s%s%s%s%s%s%s", header, GLAMOR_COMPAT_DEFINES_FS,
342342
repeat_define, relocate_texture,
343343
enable_rel_sampler ? rel_sampler : stub_rel_sampler,
344-
source_fetch, mask_fetch, dest_swizzle, in);
344+
source_fetch, mask_fetch, dest_swizzle, in) == -1)
345+
FatalError("Memory allocation on asprintf() failed\n");
345346

346347
prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
347348
free(source);
@@ -385,12 +386,13 @@ glamor_create_composite_vs(glamor_screen_private* priv, struct shader_key *key)
385386
if (priv->is_gles && priv->glsl_version > 120)
386387
version = version_gles3;
387388

388-
XNFasprintf(&source,
389+
if (asprintf(&source,
389390
"%s"
390391
GLAMOR_DEFAULT_PRECISION
391392
"%s%s%s%s%s",
392393
version, defines, main_opening, source_coords_setup,
393-
mask_coords_setup, main_closing);
394+
mask_coords_setup, main_closing) == -1)
395+
FatalError("malloc on asprintf() failed\n");
394396

395397
prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, source);
396398
free(source);

0 commit comments

Comments
 (0)