1
簡而言之,我遇到了一個問題,在調用libnotify函數時出現段錯誤。錯誤代碼:具有C函數的Segfault notify_notification_update()
int lua_libnotify_new(lua_State *L) {
const char *summary = luaL_checkstring(L, 1);
const char *body = lua_isstring(L, 2) ? lua_tostring(L, 2) : NULL;
const char *icon = lua_isstring(L, 3) ? lua_tostring(L, 3) : NULL;
NotifyNotification *notification = (NotifyNotification *)lua_newuserdata(L, sizeof(NotifyNotification));
/* Error is the below line */
notify_notification_update(notification, summary, body, icon);
return 1;
}
可否請您提供錯誤。究竟在哪裏獲得段錯誤。 – Sigstop
.CORE?你有.core轉儲?使用gdb進行調試。 – Ramy
您應該檢查所有這4個指針是否爲非NULL,除非'notify_notification_update'的文檔明確指出它的參數允許爲NULL。 –