aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornight199uk <croberts@bongle.co.uk>2013-07-22 03:03:08 -0700
committernight199uk <croberts@bongle.co.uk>2013-07-22 03:03:08 -0700
commitc18fcf270bdad36ee8ee6633d8fecd40aaa693c6 (patch)
tree00aa84b909284f786fe55434acf2d77bff6a4ea5
parentecf024b02489a13f7478b5d58868e38c535f1e3a (diff)
parent2a3ad143576fe3cdfb869126258e5f041f6794a1 (diff)
Merge pull request #2991 from night199uk/misc
[fixes] Fix a couple of EXC_BAD_ACCESS memory access bugs on OSX that cause real instability
-rw-r--r--xbmc/guilib/Texture.cpp6
-rw-r--r--xbmc/utils/Variant.cpp18
2 files changed, 17 insertions, 7 deletions
diff --git a/xbmc/guilib/Texture.cpp b/xbmc/guilib/Texture.cpp
index 3b46d0f38a..0f5edee469 100644
--- a/xbmc/guilib/Texture.cpp
+++ b/xbmc/guilib/Texture.cpp
@@ -87,7 +87,11 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
// we crash in CPicture::ScaleImage in ffmpegs swscale
// because it tries to access beyond the source memory
// (happens on osx and ios)
- m_textureWidth = ((m_textureWidth + 1) / 2) * 2;
+ // UPDATE: don't just update to be on an even width;
+ // ffmpegs swscale relies on a 16-byte stride on some systems
+ // so the textureWidth needs to be a multiple of 16. see ffmpeg
+ // swscale headers for more info.
+ m_textureWidth = ((m_textureWidth + 15) / 16) * 16;
}
// check for max texture size
diff --git a/xbmc/utils/Variant.cpp b/xbmc/utils/Variant.cpp
index bf3b41cd5c..9f5f0f2f9a 100644
--- a/xbmc/utils/Variant.cpp
+++ b/xbmc/utils/Variant.cpp
@@ -65,7 +65,8 @@ wstring trimRight(const wstring &str)
int64_t str2int64(const string &str, int64_t fallback /* = 0 */)
{
char *end = NULL;
- int64_t result = strtoll(trimRight(str).c_str(), &end, 0);
+ string tmp = trimRight(str);
+ int64_t result = strtoll(tmp.c_str(), &end, 0);
if (end == NULL || *end == '\0')
return result;
@@ -75,7 +76,8 @@ int64_t str2int64(const string &str, int64_t fallback /* = 0 */)
int64_t str2int64(const wstring &str, int64_t fallback /* = 0 */)
{
wchar_t *end = NULL;
- int64_t result = wcstoll(trimRight(str).c_str(), &end, 0);
+ wstring tmp = trimRight(str);
+ int64_t result = wcstoll(tmp.c_str(), &end, 0);
if (end == NULL || *end == '\0')
return result;
@@ -85,7 +87,8 @@ int64_t str2int64(const wstring &str, int64_t fallback /* = 0 */)
uint64_t str2uint64(const string &str, uint64_t fallback /* = 0 */)
{
char *end = NULL;
- uint64_t result = strtoull(trimRight(str).c_str(), &end, 0);
+ string tmp = trimRight(str);
+ uint64_t result = strtoull(tmp.c_str(), &end, 0);
if (end == NULL || *end == '\0')
return result;
@@ -95,7 +98,8 @@ uint64_t str2uint64(const string &str, uint64_t fallback /* = 0 */)
uint64_t str2uint64(const wstring &str, uint64_t fallback /* = 0 */)
{
wchar_t *end = NULL;
- uint64_t result = wcstoull(trimRight(str).c_str(), &end, 0);
+ wstring tmp = trimRight(str);
+ uint64_t result = wcstoull(tmp.c_str(), &end, 0);
if (end == NULL || *end == '\0')
return result;
@@ -105,7 +109,8 @@ uint64_t str2uint64(const wstring &str, uint64_t fallback /* = 0 */)
double str2double(const string &str, double fallback /* = 0.0 */)
{
char *end = NULL;
- double result = strtod(trimRight(str).c_str(), &end);
+ string tmp = trimRight(str);
+ double result = strtod(tmp.c_str(), &end);
if (end == NULL || *end == '\0')
return result;
@@ -115,7 +120,8 @@ double str2double(const string &str, double fallback /* = 0.0 */)
double str2double(const wstring &str, double fallback /* = 0.0 */)
{
wchar_t *end = NULL;
- double result = wcstod(trimRight(str).c_str(), &end);
+ wstring tmp = trimRight(str);
+ double result = wcstod(tmp.c_str(), &end);
if (end == NULL || *end == '\0')
return result;