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. resnet模型下载

    resnet模型下载: model_urls = { 'resnet18': 'https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pt ...

  2. 数据库软件mysql的卸载及安装

    mysql安装时找了好多教程,一直安装不成功,后来终于安装成了,浅写一下教程. 首先时mysql的卸载,如果安装失败或者之前下载过旧版本,那么安装时会出现start service错误,解决方法就是将 ...

  3. 盒子模型和CSS背景和列表

    盒子模型(1)宽度-width:长度值 | 百分比 | auto-max-width:长度值 | 百分比 | auto-min-width:长度值 | 百分比 | auto(2)高度-height:长 ...

  4. 2020.4.2关于java.pta的总结

    0.前言 本文是有关pta2020.3至2020.4所有面向对象程序课程(java)共三次作业的阶段性总结,是java学习最开始起步时期的成果. 1.作业过程总结 这三次作业,是从c++过渡到java ...

  5. 【JIRA】jira issue reindex

    参考文档: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Scriptrunner-Listener-Reindex ...

  6. redhat7.6配置本地yum源

    redhat7.6配置本地yum源 将光盘或者iso文件挂载到 /mnt 目录下 查看配置文件 [root@zqds122 mnt]# cat /etc/yum.repos.d/rh7ISO.repo ...

  7. 【picoCTF】GET aHEADwrite up

    打开链接,页面如下: 这道题我试了两种解法,大家都可以看看哦! 一.burpsuit拦截 1.点击bule,打开burpsuit拦截(记得打开intercept哦) 2.将 POST 请求更改为 HE ...

  8. 9. PEP8规范

    1. 每一级缩进4个空格 2. 续行时缩进要比正常行多缩进, 要能明显看出是续行的 3. 每一行最多79个字符 4. 函数和类定义时在前后加2个空行, 类内接口在定义时, 前后加1个空行 5. 二元运 ...

  9. nginx配置反向代理服务器,实现在https网站中请求http资源

    网站使用nginx作为服务器,协议从http升级为https的注意事项. 具体升级步骤请点击搜索 1.首先,修改宝塔面板配置 选择配置文件,http请求重定向为https.所有80端口请求都重定向为h ...

  10. Linux Bash Shell 中变量的 5 个易错点

    Linux 中的 Bash 脚本支持对变量的操作,下面咸鱼将介绍 Linux Bash Shell 中关于变量的 5 个易错点 因为编程习惯,这类现象往往发生在大多数使用过其他流行编程语言的程序员身上 ...