[Coverity 1666275] Dereference null return value in text_layout.c
If the function actually returns a null value, a null pointer dereference will occur.
In LayoutLine: Return value of function which returns null is dereferenced without checking (CWE-476)
19. Condition i_last_run != p_paragraph->pi_run_ids[i_paragraph_index], taking true branch.
29. Condition i_last_run != p_paragraph->pi_run_ids[i_paragraph_index], taking true branch.
39. Condition i_last_run != p_paragraph->pi_run_ids[i_paragraph_index], taking true branch.
1227 if( i_last_run != p_paragraph->pi_run_ids[ i_paragraph_index ] )
1228 {
1229 i_last_run = p_paragraph->pi_run_ids[ i_paragraph_index ];
1230 p_run = p_paragraph->p_runs + i_last_run;
1231 p_style = p_run->p_style;
1232
1233 metrics.height_px = ConvertToLiveSize( p_filter, p_style );
1234 metrics.width_px = GetFontWidthForStyle( p_style, metrics.height_px );
1235
40. returned_null: vlc_ftcache_LoadFaceByID returns NULL (checked 4 out of 5 times).[show details]
41. var_assigned: Assigning: p_face = NULL return value from vlc_ftcache_LoadFaceByID.
1236 p_face = vlc_ftcache_LoadFaceByID( p_sys->ftcache, p_run->p_faceid, &metrics );
1237 }
1238
1239 FT_Vector pen_new = {
1240 .x = pen.x + p_paragraph->p_glyph_bitmaps[ i_paragraph_index ].i_x_offset,
1241 .y = pen.y + p_paragraph->p_glyph_bitmaps[ i_paragraph_index ].i_y_offset
1242 };
1243 FT_Vector pen_shadow = {
1244 .x = pen_new.x + p_sys->f_shadow_vector_x * ( metrics.width_px << 6 ),
1245 .y = pen_new.y + p_sys->f_shadow_vector_y * ( metrics.height_px << 6 )
1246 };
1247
1248 /* Shadow being a reference to main glyph, it must be processed first */
20. Condition p_bitmaps->p_shadow, taking true branch.
21. Condition FT_Glyph_To_Bitmap(&p_bitmaps->p_shadow, FT_RENDER_MODE_NORMAL, &pen_shadow, 0), taking true branch.
30. Condition p_bitmaps->p_shadow, taking true branch.
31. Condition FT_Glyph_To_Bitmap(&p_bitmaps->p_shadow, FT_RENDER_MODE_NORMAL, &pen_shadow, 0), taking true branch.
42. Condition p_bitmaps->p_shadow, taking true branch.
43. Condition FT_Glyph_To_Bitmap(&p_bitmaps->p_shadow, FT_RENDER_MODE_NORMAL, &pen_shadow, 0), taking true branch.
1249 if( p_bitmaps->p_shadow &&
1250 FT_Glyph_To_Bitmap( &p_bitmaps->p_shadow, FT_RENDER_MODE_NORMAL,
1251 &pen_shadow, 0 ) )
1252 {
1253 p_bitmaps->p_shadow = 0;
1254 }
1255
1256 /* Ensure we don't release reference */
1257 FT_Glyph bitmapglyph = p_bitmaps->cglyph.p_glyph;
22. Condition FT_Glyph_To_Bitmap(&bitmapglyph, FT_RENDER_MODE_NORMAL, &pen_new, 0), taking true branch.
32. Condition FT_Glyph_To_Bitmap(&bitmapglyph, FT_RENDER_MODE_NORMAL, &pen_new, 0), taking true branch.
44. Condition FT_Glyph_To_Bitmap(&bitmapglyph, FT_RENDER_MODE_NORMAL, &pen_new, 0), taking false branch.
1258 if( FT_Glyph_To_Bitmap( &bitmapglyph,
1259 FT_RENDER_MODE_NORMAL,
1260 &pen_new, 0 ) )
1261 {
1262 ReleaseGlyphBitMaps( p_filter, p_bitmaps );
23. Continuing loop.
33. Continuing loop.
1263 continue;
1264 }
1265
1266 /* release the source glyph or reference */
1267 vlc_ftcache_Glyph_Release( p_sys->ftcache, &p_bitmaps->cglyph );
1268 p_bitmaps->cglyph.p_glyph = bitmapglyph;
1269
45. Condition p_bitmaps->coutline.p_glyph, taking true branch.
1270 if( p_bitmaps->coutline.p_glyph )
1271 {
1272 bitmapglyph = p_bitmaps->coutline.p_glyph;
46. Condition FT_Glyph_To_Bitmap(&bitmapglyph, FT_RENDER_MODE_NORMAL, &pen_new, 0), taking true branch.
1273 if( FT_Glyph_To_Bitmap( &bitmapglyph,
1274 FT_RENDER_MODE_NORMAL,
1275 &pen_new, 0 ) )
1276 bitmapglyph = NULL;
1277 vlc_ftcache_Custom_Glyph_Release( &p_bitmaps->coutline );
1278 p_bitmaps->coutline.p_glyph = bitmapglyph;
1279 }
1280
1281 FT_Glyph_Get_CBox( p_bitmaps->cglyph.p_glyph, FT_GLYPH_BBOX_PIXELS,
1282 &p_bitmaps->glyph_bbox );
1283 FixGlyph( p_bitmaps->cglyph.p_glyph, &p_bitmaps->glyph_bbox,
1284 p_bitmaps->i_x_advance, p_bitmaps->i_y_advance,
1285 &pen_new );
47. Condition p_bitmaps->coutline.p_glyph, taking false branch.
1286 if( p_bitmaps->coutline.p_glyph )
1287 {
1288 FT_Glyph_Get_CBox( p_bitmaps->coutline.p_glyph, FT_GLYPH_BBOX_PIXELS,
1289 &p_bitmaps->outline_bbox );
1290 FixGlyph( p_bitmaps->coutline.p_glyph, &p_bitmaps->outline_bbox,
1291 p_bitmaps->i_x_advance, p_bitmaps->i_y_advance,
1292 &pen_new );
1293 }
48. Condition p_bitmaps->p_shadow, taking false branch.
1294 if( p_bitmaps->p_shadow )
1295 {
1296 FT_Glyph_Get_CBox( p_bitmaps->p_shadow, FT_GLYPH_BBOX_PIXELS,
1297 &p_bitmaps->shadow_bbox );
1298 FixGlyph( p_bitmaps->p_shadow, &p_bitmaps->shadow_bbox,
1299 p_bitmaps->i_x_advance, p_bitmaps->i_y_advance,
1300 &pen_shadow );
1301 }
1302
1303 int i_line_offset = 0;
1304 int i_line_thickness = 0;
1305
49. Condition p_ch->p_style->i_style_flags & (96 /* (1 << 5) | (1 << 6) */), taking true branch.
1306 if( p_ch->p_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
1307 {
CID 1666275: (#1 of 1): Dereference null return value (NULL_RETURNS)
50. dereference: Dereferencing p_face, which is known to be NULL.
CID 1346944:Dereference after null check (FORWARD_NULL) [ "select issue" ]
1308 i_line_offset =
1309 labs( FT_FLOOR( FT_MulFix( p_face->underline_position,
1310 p_face->size->metrics.y_scale ) ) );