project-navigation
Personal tools

Author Topic: Segmentation fault when starting  (Read 1677 times)

denis

  • Guest
Segmentation fault when starting
« on: August 16, 2010, 09:17:25 pm »
On revision 31530.
I have a Segmentation fault at launch of ./ufo
After few investigation, I found the issue.
On function R_UploadTexture (src/client/renderer/r_image.c);
There is a loop for c = scaledWidth * scaledHeight; element (line 319)
When loading image "base/pics/ui/base_bg" (size 1024 x 768), scaledWidth and scaledHeight are computed to 1024 and 1024 by R_GetScaledTextureSize.
The loop looks for a out memory adress in this case. The size of the picture is 1024 x 768 and the loop is for 1024 x 1024.

I have test the following change and it solves my issue.

#svn diff src/client/renderer/r_image.c
Index: src/client/renderer/r_image.c
===================================================================
--- src/client/renderer/r_image.c   (revision 31530)
+++ src/client/renderer/r_image.c   (working copy)
@@ -314,7 +314,7 @@
    R_GetScaledTextureSize(width, height, &scaledWidth, &scaledHeight);
 
    /* scan the texture for any non-255 alpha */
-   c = scaledWidth * scaledHeight;
+   c = width * height;
    /* set scan to the first alpha byte */
    for (i = 0, scan = ((byte *) data) + 3; i < c; i++, scan += 4) {
       if (*scan != 255) {


Another question is how to report bug (and fixes)?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Segmentation fault when starting
« Reply #1 on: August 16, 2010, 09:26:13 pm »