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的更多相关文章

  1. Unity性能优化(2)-官方教程Diagnosing performance problems using the Profiler window翻译

    本文是Unity官方教程,性能优化系列的第二篇<Diagnosing performance problems using the Profiler window>的简单翻译. 相关文章: ...

  2. 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监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...

  3. Problems about trees

    Problems (1) 给一棵带边权的树,求遍历这棵树(每个节点至少经过一次)再回到起点的最短路程. 答案是显然的:边权之和的两倍. (2)给一棵带边权的树,求遍历这棵树(每个节点至少经过一次)的最 ...

  4. Problems with MMM for mysql(译文)

    Problems with mmm for mysql posted in MySQL by shlomi 原文:http://code.openark.org/blog/mysql/problems ...

  5. Javascript > Eclipse > problems encountered during text search

    Reproduce: Ctrl + H, Select "File Search", will encounter eclipse kinds of bug/error alert ...

  6. E: Unable to correct problems, you have held broken packages 解决方法

    在Ubuntu中安装软件的时候经常碰到E: Unable to correct problems, you have held broken packages.的错误,顾名思义是因为某些软件包冲突导致 ...

  7. ubuntu 'Unable to correct problems, you have held broken packages' 错误

    在用apt 安装软件时,有时会用国内的源以加快下载速度. 但是在使用ubuntu 14.04的过程中,这一过程可能会导致错误“Unable to correct problems, you have ...

  8. POJ 2151 Check the difficulty of problems

    以前做过的题目了....补集+DP        Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K ...

  9. ios 关于[xxx timeIntervalSinceNow]出现EXC_BAD_ACCESS错误的解决办法

    [xxx timeIntervalSinceNow]出现EXC_BAD_ACCESS错误的主要原因是之前的[NSDate date]返回一个autoreleased的NSdata,其被释放掉 解决方法 ...

  10. 当编译CCBReader时出现 “ CCBAnimationManager.m Use of undeclared identifier 'other‘ ” 解决方法

    第一种解决方法是去github上下载最新的CCBReader 第二种解决方法是把other替换成self.inner 建议用新版本的

随机推荐

  1. git push错误failed to push some refs to的解决

    问题说明 当我们在github版本库中发现一个问题后,你在github上对它进行了在线的修改:或者你直接在github上的某个库中添加readme文件或者其他什么文件,但是没有对本地库进行同步.这个时 ...

  2. Lombok和MapStruct冲突

    Lombok和MapStruct冲突导致无法生成正确的class文件. lombok自动生成getset等冗余代码. MapStruct对象copy.传统的BeanUtils.copy等利用的反射原理 ...

  3. tensorflow的断点续训

    tensorflow的断点续训 2019-09-07 顾名思义,断点续训的意思是因为某些原因模型还没有训练完成就被中断,下一次训练可以在上一次训练的基础上继续训练而不用从头开始:这种方式对于你那些训练 ...

  4. C/C++ 数据结构循环队列的实现

    #include <iostream> #include <Windows.h> using namespace std; #define MAXSIZE 6 typedef ...

  5. 怎样清空 DNS 缓存?

    在 Windows 下命令行执行:ipconfig /flushdns 在 macOS 下执行命令:sudo killall -HUP mDNSResponder

  6. junit单元测试踩过的坑

    1.测试方法不能直接获取到系统初始化的配置信息,需要专门读取 2.单元测试多线程子线程不执行,不会像主线程一样等待子线程退出而退出, 会直接退出. . https://blog.csdn.net/yu ...

  7. 适用于 Linux 的 Windows 子系统使用 Visual Studio Code

    在WSL中使用VS Code,先在Windows中安装vscode,再通过功能扩展安装Vscode for wsl. VSCode 有system和user两个版本,默认下载链接为user版本.以下内 ...

  8. Spring注解和一些类

    Spring基础相关 声明Bean,类注解 @Component@Service@Repository IOC,自动注入,属性注解 @AutoWired @Resource @Inject 其他 @I ...

  9. OSPF v3与v2的区别

  10. vs2010 Windows程序打包成安装包方法

    1.  在vs2010 选择"新建项目"--"其他项目类型"--"Visual Studio Installerà"安装项目": ...