Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • xserver xserver
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 887
    • Issues 887
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 106
    • Merge requests 106
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • xorg
  • xserverxserver
  • Merge requests
  • !859

[Backport to xwayland-22.1] render: Fix build with gcc 12

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Olivier Fourdan requested to merge ofourdan/xserver:xwayland-22.1-fix-build-with-gcc-12 into xwayland-22.1 Jan 28, 2022
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

The xserver fails to compile with the latest gcc 12:

 render/picture.c: In function ‘CreateSolidPicture’:
 render/picture.c:874:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
  874 |     pPicture->pSourcePict->type = SourcePictTypeSolidFill;
      |                          ^~
 render/picture.c:868:45: note: object of size 16 allocated by ‘malloc’
  868 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictSolidFill));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 render/picture.c: In function ‘CreateLinearGradientPicture’:
 render/picture.c:906:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Werror=array-bounds]
  906 |     pPicture->pSourcePict->linear.type = SourcePictTypeLinear;
      |                          ^~
 render/picture.c:899:45: note: object of size 32 allocated by ‘malloc’
  899 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictLinearGradient));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 render/picture.c: In function ‘CreateConicalGradientPicture’:
 render/picture.c:989:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Werror=array-bounds]
  989 |     pPicture->pSourcePict->conical.type = SourcePictTypeConical;
      |                          ^~
 render/picture.c:982:45: note: object of size 32 allocated by ‘malloc’
  982 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictConicalGradient));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 cc1: some warnings being treated as errors
 ninja: build stopped: subcommand failed.

This is because gcc 12 has become stricter and raises a warning now.

Fix the warning/error by allocating enough memory to store the union struct.

Signed-off-by: Olivier Fourdan ofourdan@redhat.com Acked-by: Michel Dänzer mdaenzer@redhat.com Closes: #1256 (closed) (cherry picked from commit c6b0dcb8)

Edited Jan 28, 2022 by Olivier Fourdan
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: xwayland-22.1-fix-build-with-gcc-12