From 0fc3bd182e16ef33ea6a53e65728782f8a5ba6c8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 11 Feb 2008 17:07:32 +0100 Subject: [PATCH] Fixed a bug in displaying of zlib errors. --- ChangeLog | 6 ++++++ lib/names.c | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8165ee6..20df7a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-11 Martin Mares + + * lib/names.c: Fix displaying of errors reported by zlib. + Previously, the buffer containing the error message had + been deallocated by gzclose() before the message was printed. + 2008-01-07 Martin Mares * update-pciids.sh: Added quiet mode (-q). Clean up uncompressed diff --git a/lib/names.c b/lib/names.c index eee2f19..64b5c27 100644 --- a/lib/names.c +++ b/lib/names.c @@ -1,7 +1,7 @@ /* * The PCI Library -- ID to Name Translation * - * Copyright (c) 1997--2007 Martin Mares + * Copyright (c) 1997--2008 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -43,9 +43,10 @@ static pci_file pci_open(struct pci_access *a) #define PCI_ERROR(f, err) \ if (!err) { \ int errnum; \ - err = gzerror(f, &errnum); \ - if (errnum == Z_ERRNO) err = "I/O error"; \ - else if (errnum >= 0) err = NULL; \ + gzerror(f, &errnum); \ + if (errnum >= 0) err = NULL; \ + else if (errnum == Z_ERRNO) err = "I/O error"; \ + else err = zError(errnum); \ } #else typedef FILE * pci_file; -- 2.39.2