diff -ur hexedit-0.9.7_old/src/hexedit.h hexedit-0.9.7_new/src/hexedit.h
--- hexedit-0.9.7_old/src/hexedit.h	1999-08-08 04:20:38.000000000 +0200
+++ hexedit-0.9.7_new/src/hexedit.h	2019-01-11 21:08:19.855040974 +0100
@@ -34,6 +34,10 @@
 #include <limits.h>
 #endif
 
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 #ifdef STDC_HEADERS
 #include <stdlib.h>
 #include <string.h>
diff -ur hexedit-0.9.7_old/src/search.c hexedit-0.9.7_new/src/search.c
--- hexedit-0.9.7_old/src/search.c	1999-06-27 15:45:29.000000000 +0200
+++ hexedit-0.9.7_new/src/search.c	2019-01-11 21:08:44.285042036 +0100
@@ -39,7 +39,7 @@
    if (!buf)
       return &found;
 
-   memset (l_table, 0, 256 * sizeof (int));
+   memset (l_table, 0, sizeof (l_table));
    i = 0;
    s = substr + len - 1;
    while (i < len)
diff -ur hexedit-0.9.7_old/src/widgets.c hexedit-0.9.7_new/src/widgets.c
--- hexedit-0.9.7_old/src/widgets.c	1999-06-28 22:51:01.000000000 +0200
+++ hexedit-0.9.7_new/src/widgets.c	2019-01-11 21:11:17.721715362 +0100
@@ -62,22 +62,20 @@
 
    wmove (win, y, x);
    wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE);
-   str = malloc (len + 2);
+   str = malloc (len + 1);
    if (!str)
    {
 /*      fprintf (stderr, "%s - StringBox\n", NOT_ENOUGH_MEMORY); */
       popup_Error (NOT_ENOUGH_MEMORY, 0);
       return NULL;
    }
-   *(str + len + 1) = '\0';
-   memset (str, ' ', len + 1);
-   strncpy (str, sample ? sample : "", samplelen);
+   memset (str, 0, len + 1);
+   if (sample)
+      strncpy (str, sample, samplelen);
    for (i = 0; i < max; i++)
    {
-      if (*(str + i) && (i < max))
-      {
+      if (*(str + i))
          wprintw (win, "%c", *(str + i));
-      }
       else
          wprintw (win, " ");
    }
@@ -170,10 +168,10 @@
                {
                   i--;
                   for (n = strlen (str); n < len; n++)
-                     *(str + n) = ' ';
+                     *(str + n) = 0;
                   for (n = i; n < len; n++)
                      *(str + n) = *(str + n + 1);
-                  *(str + n) = ' ';
+                  *(str + n) = 0;
                   oldx = win->_curx;
                   wmove (win, y, x);
                   for (n = left; n <= right; n++)
@@ -220,7 +218,7 @@
                   *(str + n) = *(str + n - 1);
                }
                *(str + i) = ' ';
-               *(str + len) = ' ';
+               *(str + len) = 0;
                i++;
                wmove (win, y, x);
                for (n = left; n <= right; n++)
@@ -240,7 +238,7 @@
                   *(str + n) = *(str + n - 1);
                }
                *(str + i) = ' ';
-               *(str + len) = ' ';
+               *(str + len) = 0;
                i++;
                if (right < len - 1)
                {
diff -ur hexedit-0.9.7_old/src/windows.c hexedit-0.9.7_new/src/windows.c
--- hexedit-0.9.7_old/src/windows.c	1999-08-08 04:51:11.000000000 +0200
+++ hexedit-0.9.7_new/src/windows.c	2019-01-11 21:07:46.575039528 +0100
@@ -253,7 +253,7 @@
    filename = stringBox (wpopup, 3, 2 + strlen ("Filename: "), 
                       FILE_SAVE_STRING_BOX_MAX,
                       FILE_SAVE_STRING_BOX, (char *) Globals.filename);
-   chompWhiteSpace (filename);
+/*   chompWhiteSpace (filename); */
 
    if (!filename);
    else if (!*filename)
@@ -635,15 +635,10 @@
                          SEARCH_STRING_BOX, NULL);
       s = (unsigned char *) str;
       laststr = s;
-      for (str = s + SEARCH_STRING_BOX_MAX - 1; str != (s - 1); str--)
-      {
-         if (*str != ' ')
-         {
-            *(str + 1) = '\0';
-            done = 1;
-            break;
-         }
-      }
+
+      if (*s)
+         done = 1;
+
       if (Globals.charset == EBCDIC_CHAR_SET)
       {
          unsigned char *p = s;
@@ -697,20 +692,21 @@
             spot = boyer_moore_search (retr->str, offset + 1,
                                  last_str_len = retr->len,
                                  Globals.filesize - offset);
+         if (laststr)
+            free (laststr);
+         laststr = malloc (retr->len + 1);
+         memset (laststr, 0x00, retr->len + 1);
+         memcpy (laststr, retr->str, retr->len);
+         free (retr->str);
+         retr->str = NULL;
+         retr->len = 0;
+
          if (spot && spot->flag)
          {
             offset += spot->offset + 1; /* started search one character
                                           ahead of offset */
             cursor_y = 1;
             cursor_x = mappos (offset & M_0x0F);
-            if (laststr)
-               free (laststr);
-            laststr = malloc (retr->len + 1);
-            memset (laststr, 0x00, retr->len + 1);
-            memcpy (laststr, retr->str, retr->len);
-            free (retr->str);
-            retr->str = NULL;
-            retr->len = 0;
          }
          else
          {
