Skip to content

NgxStr Default 问题 #150

@wulin-cn

Description

@wulin-cn

我在获取 user_agent 的时候使用的 unwrap_or_default

let ua = request.user_agent().unwrap_or_default();

当客户端请求的 UA 为空时,子进程会直接崩溃重启。

let str: &NgxStr = Default::default();
println!("{:?}", str.as_bytes());

做了测试,NgxStr default 调用 as_bytes 方法会报错:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions