Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不支持bmp图片文件,不支持的文件打开后没有关闭 #13

Open
hansdcr opened this issue Dec 8, 2016 · 0 comments
Open

不支持bmp图片文件,不支持的文件打开后没有关闭 #13

hansdcr opened this issue Dec 8, 2016 · 0 comments

Comments

@hansdcr
Copy link

hansdcr commented Dec 8, 2016

static int get_ext_header(char *filename)
{
FILE *handle;
handle = fopen(filename, "rb");
int ret = NGX_IMAGE_NONE; //添加处理,访问格式不存在时关闭打开的文件

if(!handle) {
    return NGX_IMAGE_NONE;
} else {
    unsigned short filetype;//bmp 0x4D42
    if(fread(&filetype, sizeof(unsigned short), 1, handle)) {
        if( filetype == 0xD8FF) {
            ret = NGX_IMAGE_JPEG;
        } else if( filetype == 0x4947) {
            ret = NGX_IMAGE_GIF;
        } else if( filetype == 0x5089) {
            ret = NGX_IMAGE_PNG;
        } else if ( filetype == 0x4d42) {
            ret = NGX_IMAGE_BMP; //添加处理bmp格式
        }

#if 0
else {
ret = NGX_IMAGE_NONE;
}
#endif
}
}
fclose(handle);
return ret;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant