changeset 26960:805f7deb1b48

Ensure 'path' string is 0 terminated. Patch by Guillaume Lecerf <foxcore at gmail com>
author ben
date Thu, 05 Jun 2008 19:46:16 +0000
parents bab42914ea63
children 173347ab9083
files libmenu/menu_filesel.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/menu_filesel.c	Wed Jun 04 20:15:04 2008 +0000
+++ b/libmenu/menu_filesel.c	Thu Jun 05 19:46:16 2008 +0000
@@ -410,10 +410,10 @@
       if (path_fp >= 0) {
         if (!fstat (path_fp, &st) && (st.st_size > 0)) {
           path = malloc(st.st_size+1);
+          path[st.st_size] = '\0';
           if ((read(path_fp, path, st.st_size) == st.st_size) && path[0] == '/'
               && !stat(path, &st) && S_ISDIR(st.st_mode)){
             freepath = path;
-            path[st.st_size] = '\0';
           }
           else {
             free(path);