Skip to content

对内存分配检查 NULL 返回 #866

@viennadd

Description

@viennadd

我们利用工具扫描开源项目,发现大多数 nginx 使用 ngx_pnalloc 时都有对分配失败进行 NULL 检查,因为如果内存池闲余不足够,ngx_pnalloc 还是会再向系统申请,就有可能分配失败。

ngx_pipe.c#L36 调用 ngx_pnalloc 时不检查内存分配是否成功就继续复制字符到新分配空间。

    dup = ngx_pnalloc(cycle->pool, cmd->len + 1);
    (void) ngx_cpystrn(dup, cmd->data, cmd->len + 1);

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