Skip to content

Commit 235187d

Browse files
author
v_yholu
committed
修复海马运行崩溃
1 parent d75cc1d commit 235187d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ijkmedia/ijkplayer/ff_ffmsg_queue.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,25 @@ inline static void msg_queue_put_simple4(MessageQueue *q, int what, int arg1, in
156156
msg.what = what;
157157
msg.arg1 = arg1;
158158
msg.arg2 = arg2;
159+
160+
// 分配内存并检查是否成功
159161
msg.obj = av_malloc(obj_len);
162+
if (!msg.obj) {
163+
av_log(NULL, AV_LOG_ERROR, "msg_queue_put_simple4: 内存分配失败 size=%d\n", obj_len);
164+
return;
165+
}
166+
167+
// 安全拷贝数据
160168
memcpy(msg.obj, obj, obj_len);
161169
msg.free_l = msg_obj_free_l;
170+
171+
// 放入队列
172+
if (msg_queue_put(q, &msg) < 0) {
173+
// 如果放入队列失败,释放已分配的内存
174+
msg_obj_free_l(msg.obj);
175+
av_log(NULL, AV_LOG_WARNING, "msg_queue_put_simple4: 放入消息队列失败\n");
176+
}
177+
162178
msg_queue_put(q, &msg);
163179
}
164180

0 commit comments

Comments
 (0)