Skip to content

Commit

Permalink
修复字符串过长是导致的crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ikeshi committed Jun 4, 2020
1 parent fcdf9aa commit 013b2d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MangoFix.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MangoFix"
s.version = "1.4.1"
s.version = "1.4.2"
s.summary = "MangoFix"
s.description = <<-DESC
Mango is a DSL which syntax is very similar to Objective-C,Mango is also an iOS App hotfix SDK. You can use Mango method replace any Objective-C method.
Expand Down
5 changes: 3 additions & 2 deletions MangoFix/Compiler/create.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void mf_open_string_literal_buf(){
void mf_append_string_literal(int letter){
if (st_string_literal_buffer_size >= st_string_literal_buffer_alloc_size) {
st_string_literal_buffer_alloc_size += STRING_ALLOC_SIZE;
void *new_pointer = realloc(st_string_literal_buffer, st_string_literal_buffer_alloc_size);
char *new_pointer = calloc(st_string_literal_buffer_alloc_size,1);
memcpy(new_pointer, st_string_literal_buffer, st_string_literal_buffer_size);
free(st_string_literal_buffer);
st_string_literal_buffer = new_pointer;
}
Expand All @@ -63,7 +64,7 @@ void mf_rest_string_literal_buffer(void){
const char *mf_end_string_literal(){
mf_append_string_literal('\0');
size_t strLen = strlen(st_string_literal_buffer);
char *str = malloc(strLen + 1);
char *str = calloc(strLen + 1, 1);
strcpy(str, st_string_literal_buffer);
mf_rest_string_literal_buffer();
return str;
Expand Down
7 changes: 7 additions & 0 deletions MangoFixDemo/MangoFixDemo/demo.mg
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ class SubMyController:SuperMyController {
self.view.addSubview:(view);
view.backgroundColor = UIColor.redColor();
self.rotateView = view;


UILabel *label = UILabel.alloc().initWithFrame:(CGRectMake(10, 80, 350, 600));
label.numberOfLines = 100;
label.text =@" 长文本测试 : select()机制中提供一fd_set的数据结构,实际上是一long类型的数组,每一个数组元素都能与一打开的文件句柄(不管是socket句柄,还是其他文件或命名管道或设备句柄)建立联系,建立联系的工作由程序员完成,当调用select()时,由内核根据IO状态修改fd_set的内容,由此来通知执行了select()的进程哪一socket或文件发生了可读或可写事件。select()机制中提供一fd_set的数据结构,实际上是一long类型的数组,每一个数组元素都能与一打开的文件句柄(不管是socket句柄,还是其他文件或命名管道或设备句柄)建立联系,建立联系的工作由程序员完成,当调用select()时,由内核根据IO状态修改fd_set的内容,由此来通知执行了select()的进程哪一socket或文件发生了可读或可写事件。select()机制中提供一fd_set的数据结构,实际上是一long类型的数组,每一个数组元素都能与一打开的文件句柄(不管是socket句柄,还是其他文件或命名管道或设备句柄)建立联系,建立联系的工作由程序员完成,当调用select()时,由内核根据IO状态修改fd_set的内容,由此来通知执行了select()的进程哪一socket或文件发生了可读或可写事件。select()机制中提供一fd_set的数据结构,实际上是一long类型的数组,每一个数组元素都能与一打开的文件句柄(不管是socket句柄,还是其他文件或命名管道或设备句柄)建立联系,建立联系的工作由程序员完成,当调用select()时,由内核根据IO状态修改fd_set的内容,由此来通知执行了select()的进程哪一socket或文件发生了可读或可写事件。";
self.view.addSubview:(label);



__weak id weakSelf = self;
Expand Down
8 changes: 4 additions & 4 deletions MangoFixDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PODS:
- MangoFix (1.4.0)
- MangoFix (1.4.1)
- Masonry (1.1.0)

DEPENDENCIES:
- MangoFix (from `../`)
- Masonry

SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- Masonry

EXTERNAL SOURCES:
MangoFix:
:path: "../"

SPEC CHECKSUMS:
MangoFix: 3ffa5f7ee6eaf3e48d79df0abc5975bf7171c728
MangoFix: 973ab9e2cd5d0abef69cb5b62b5b9c3da23c7cd0
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201

PODFILE CHECKSUM: 911a1bb3fd9799c1577d16ea8d90314d90fb35f1

COCOAPODS: 1.7.5
COCOAPODS: 1.9.1

0 comments on commit 013b2d1

Please sign in to comment.