@@ -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 );
0 commit comments