Search code examples
cluagtklibnotify

Segfault with C function notify_notification_update()


Simply enough, I'm having an issue where I'm getting a segfault when calling a libnotify function. Erroring code:

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;
}

Solution

  • After some tinkering, I realized that it should've been sizeof(NotifyNotification*). Resolved.