From d3b9f446a683f71b0d3a70ecf6e0028a063040e4 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 3 Jan 2013 22:37:44 -0700 Subject: fix for MAINT-2147: crash in LLTextureCache::writeToFastCache on OSX --- indra/newview/lltexturecache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 305f6fca0f..102b97de30 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1912,10 +1912,10 @@ bool LLTextureCache::writeToFastCache(S32 id, LLPointer raw, S32 dis h >>= i; if(w * h *c > 0) //valid { - LLPointer newraw = new LLImageRaw(raw->getData(), raw->getWidth(), raw->getHeight(), raw->getComponents()); - newraw->scale(w, h) ; - raw = newraw; - + //make a duplicate to keep the original raw image untouched. + raw = raw->duplicate(); + raw->scale(w, h) ; + discardlevel += i ; } } -- cgit v1.2.3 From f62d04d4256e3ebb7ecf64ea370099c8795e8581 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 14 Jun 2013 11:32:12 -0700 Subject: MAINT-2791: Yet another crash in LLTextureCache::writeToFastCache(). Reviewed by Kelly --- indra/newview/lltexturecache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 102b97de30..e030851138 100755 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1925,9 +1925,12 @@ bool LLTextureCache::writeToFastCache(S32 id, LLPointer raw, S32 dis memcpy(mFastCachePadBuffer + sizeof(S32), &h, sizeof(S32)); memcpy(mFastCachePadBuffer + sizeof(S32) * 2, &c, sizeof(S32)); memcpy(mFastCachePadBuffer + sizeof(S32) * 3, &discardlevel, sizeof(S32)); - if(w * h * c > 0) //valid + + S32 copy_size = w * h * c; + if(copy_size > 0) //valid { - memcpy(mFastCachePadBuffer + TEXTURE_FAST_CACHE_ENTRY_OVERHEAD, raw->getData(), w * h * c); + copy_size = llmin(copy_size, TEXTURE_FAST_CACHE_ENTRY_SIZE - TEXTURE_FAST_CACHE_ENTRY_OVERHEAD); + memcpy(mFastCachePadBuffer + TEXTURE_FAST_CACHE_ENTRY_OVERHEAD, raw->getData(), copy_size); } S32 offset = id * TEXTURE_FAST_CACHE_ENTRY_SIZE; -- cgit v1.2.3