From 1a71a84b6268bd24a306f7bad87cdd88c2d95e78 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 18 Aug 2014 17:15:57 +0100 Subject: cope with error return from ftell (coverity 1231843) --- framebuffer/convert_font.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/framebuffer/convert_font.c b/framebuffer/convert_font.c index a43b31d7d..7c7a16a4f 100644 --- a/framebuffer/convert_font.c +++ b/framebuffer/convert_font.c @@ -2,19 +2,26 @@ * Copyright 2014 Michael Drake * Copyright 2014 Vincent Sanders * - * This file is part of NetSurf, http://www.netsurf-browser.org/ + * This file is part of the convert_font tool used to convert font + * glyph data into a compilable representation. * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include @@ -1031,6 +1038,12 @@ bool load_font(const char *path, struct font_data **data) /* Find filesize */ fseek(fp, 0L, SEEK_END); file_len = ftell(fp); + if (file_len == -1) { + LOG(LOG_ERROR, "Could not size input file\n"); + free(d); + fclose(fp); + return false; + } fseek(fp, 0L, SEEK_SET); LOG(LOG_DEBUG, "Input size: %zu bytes\n", file_len); -- cgit v1.2.3