groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: lkbib with empty file dumps core


From: Carsten Kunze
Subject: [groff] 01/01: lkbib with empty file dumps core
Date: Fri, 28 Apr 2017 17:57:17 -0400 (EDT)

carstenkunze pushed a commit to branch master
in repository groff.

commit 2ac1f9ba5578cad27dc547d5be3c91753db436ea
Author: Osamu Sayama <sayama>
Date:   Fri Apr 28 23:56:15 2017 +0200

    lkbib with empty file dumps core
    
    See https://savannah.gnu.org/bugs/?48433
---
 ChangeLog                 | 9 +++++++++
 src/libs/libbib/index.cpp | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 1bf4c15..041a7f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-04-28  Osamu Sayama
+
+       lkbib with empty file dumps core
+
+       * src/libs/libbib/index.cpp: Test if argument to malloc(3)
+       is zero.
+
+       See https://savannah.gnu.org/bugs/?48433
+
 2017-04-28  David Gilman
 
        Typo in groff.texi
diff --git a/src/libs/libbib/index.cpp b/src/libs/libbib/index.cpp
index ea4df53..9958d13 100644
--- a/src/libs/libbib/index.cpp
+++ b/src/libs/libbib/index.cpp
@@ -158,6 +158,10 @@ int index_search_item::load(int fd)
   }
   mtime = sb.st_mtime;
   int size = int(sb.st_size);
+  if (size == 0) {
+    error("`%1' is an empty file", name);
+    return 0;
+  }
   char *addr;
   map_addr = mapread(fd, size);
   if (map_addr) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]