diff options
author | Nanley Chery <nanley.g.chery@intel.com> | 2015-08-12 21:09:19 -0700 |
---|---|---|
committer | Nanley Chery <nanley.g.chery@intel.com> | 2015-08-12 21:09:19 -0700 |
commit | a189ea567f9a647c79e4e35483e81a9ec42e0243 (patch) | |
tree | dc9220f7fea483a86d42e72f4bb0c306205ff938 | |
parent | 447440475ae670780478d428c844962f43c42371 (diff) |
gen_mipmaps: fix segfault.
-rw-r--r-- | gen_mipmaps.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gen_mipmaps.c b/gen_mipmaps.c index d70bea2..d8c3b0d 100644 --- a/gen_mipmaps.c +++ b/gen_mipmaps.c @@ -182,7 +182,9 @@ main(int argc, char *argv[]) /* Convert miplevel to the original image's format */ if (tex_info.glFormat != ltex_info.glFormat) { - printf("MIPLEVEL %d: Different glFormat!\n", cur_lev); + printf("MIPLEVEL %d: Different glFormat!\ncomps: %d vs %d\n", cur_lev, + _mesa_components_in_format(tex_info.glFormat), + _mesa_components_in_format(ltex_info.glFormat)); /* Conversion step */ GLsizei lsize2 = ltex_info.pixelHeight * ltex_info.pixelWidth * _mesa_bytes_per_pixel(tex_info.glFormat, tex_info.glType) ; GLubyte *ldata2 = (GLubyte*) malloc(lsize2); @@ -190,9 +192,10 @@ main(int argc, char *argv[]) puts("malloc failed"); int offset = 0; int offset2 = 0; - for (; offset != *lsize; offset+=3) { + while (offset < lsize2) { memcpy(ldata2 + offset2, *ldata+offset, 3); ldata2[offset2+3] = 255; + offset+=3; offset2+=4; } /* Saving step */ |