Problems with EXC_BAD_ACCESS in CCBReader
Hi guys,
I've found problems using the CCBReader when deploying my game to an iPhone 4.
There are several potential lines in CCBReader where the game will crash due to memory misalignment.
in CCBReader::readHeader()
int magicBytes = *((int*)(this->mBytes + this->mCurrentByte));
should be
int magicBytes;unsigned char* pData = ( this->mBytes + this->mCurrentByte );memcpy( &magicBytes, pData, sizeof( int ) );
in CCBReader::readFloat() there is something really dangerous
float * pF = (float*)(this->mBytes + this->mCurrentByte);float f = 0;memcpy(&f, pF, sizeof(float));
should be
float f;unsigned char* pData = ( this->mBytes + this->mCurrentByte );memcpy( &f, pData, sizeof( float ) );
The ARM processor which is inside all iPhones, iPads, etc. Doesn't like memory
misalignment! so be careful doing castings with memory which could be misalignment
after the casting!
You can find more info about this issue here:
http://stackoverflow.com/questions/3243146/why-does-this-exc-bad-access-happen-with-long-long-and-not-with-int
http://stackoverflow.com/questions/7788216/exc-bad-access-and-char-pointer-to-float-pointer-cast
Problems with EXC_BAD_ACCESS in CCBReader的更多相关文章
- Unity性能优化(2)-官方教程Diagnosing performance problems using the Profiler window翻译
本文是Unity官方教程,性能优化系列的第二篇<Diagnosing performance problems using the Profiler window>的简单翻译. 相关文章: ...
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...
- Problems about trees
Problems (1) 给一棵带边权的树,求遍历这棵树(每个节点至少经过一次)再回到起点的最短路程. 答案是显然的:边权之和的两倍. (2)给一棵带边权的树,求遍历这棵树(每个节点至少经过一次)的最 ...
- Problems with MMM for mysql(译文)
Problems with mmm for mysql posted in MySQL by shlomi 原文:http://code.openark.org/blog/mysql/problems ...
- Javascript > Eclipse > problems encountered during text search
Reproduce: Ctrl + H, Select "File Search", will encounter eclipse kinds of bug/error alert ...
- E: Unable to correct problems, you have held broken packages 解决方法
在Ubuntu中安装软件的时候经常碰到E: Unable to correct problems, you have held broken packages.的错误,顾名思义是因为某些软件包冲突导致 ...
- ubuntu 'Unable to correct problems, you have held broken packages' 错误
在用apt 安装软件时,有时会用国内的源以加快下载速度. 但是在使用ubuntu 14.04的过程中,这一过程可能会导致错误“Unable to correct problems, you have ...
- POJ 2151 Check the difficulty of problems
以前做过的题目了....补集+DP Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K ...
- ios 关于[xxx timeIntervalSinceNow]出现EXC_BAD_ACCESS错误的解决办法
[xxx timeIntervalSinceNow]出现EXC_BAD_ACCESS错误的主要原因是之前的[NSDate date]返回一个autoreleased的NSdata,其被释放掉 解决方法 ...
- 当编译CCBReader时出现 “ CCBAnimationManager.m Use of undeclared identifier 'other‘ ” 解决方法
第一种解决方法是去github上下载最新的CCBReader 第二种解决方法是把other替换成self.inner 建议用新版本的
随机推荐
- Windows server 防火墙开放oracle监听端口
Windows server 防火墙开放oracle监听端口 Windows server 2008 开放1521端口 Windows server 2003 开放监听程序例外先开防火墙,再开监听例外 ...
- LeetCode刷题4:寻找两个正序数组的中位数
题目: 给定两个大小分别为 m 和 n 的正序(从小到大)数组 nums1 和 nums2.请你找出并返回这两个正序数组的 中位数 . 算法的时间复杂度应该为 O(log (m+n)) . 来源:力扣 ...
- mssql实现Split
create function Fun_Split( @SourceSql varchar ( 8000 ), @StrSeprate varchar ( 10 )) returns @temp ta ...
- 复杂数据类型(signal)的解读-C语言基础
这一篇文章要探讨的是C语言中复杂数据类型的解读.涉及到signal()函数数据类型的解读(并不解释signal()的作用)以及对于数据类型的理解,属于C语言基础篇. 在开始解读signal()这种复杂 ...
- git—分支设置
什么是分支? 项目以上线,但需要开发新的功能.不能直接在项目上进行开发的,这时候就需要创建一个分支,去完成新功能的开发.测试等.完成之后合并到主分支上面.如果新功能的开发不用分支,导致的问题就会有很多 ...
- Manage your references to .Net assemblies Dynamics 365 for Operations VS projects
(Dynamics 365 for Operations was previously known as the New Dynamics AX) Dynamics 365 for Operation ...
- java 多线程 数据通信
1.司机等乘客全部上车后再启动车子 import java.util.concurrent.CountDownLatch;public class A { public static void mai ...
- Python第十章实验报告
一.实验对象:<零基础学Python>6道实例和2道实战 二.实验环境:IDLE Shell 3.9.7 三.实验目的:学习如何在Python中进行文件和目录的相关操作 四.实验过程: 实 ...
- arpspoof、driftnet工具使用
一.arpspoof.driftnet工具安装: 在kali liux中: 安装命令:apt install dsniff apt install driftnet 二.使用arpspoof ...
- 万字血书Vue—路由
多个路由通过路由器进行管理. 前端路由的概念和原理 (编程中的)路由(router)就是一组key-value对应关系,分为:后端路由和前端路由 后端路由指的是:请求方式.请求地址和function处 ...