fix dangling pointer issues in ext2dr
[lunaix-os.git] / lunaix-os / kernel / fs / xattr.c
index 94f85b76dce7489708124e87a8a34f7988e4451d..1b17b3d62a12005ea990f467eb38060d99d7306a 100644 (file)
@@ -1,7 +1,9 @@
 #include <klibc/string.h>
 #include <lunaix/fs.h>
 #include <lunaix/mm/valloc.h>
+#include <lunaix/process.h>
 #include <lunaix/syscall.h>
+#include <lunaix/syscall_utils.h>
 
 struct v_xattr_entry*
 xattr_new(struct hstr* name)
@@ -11,7 +13,8 @@ xattr_new(struct hstr* name)
         return NULL;
     }
     *entry =
-      (struct v_xattr_entry){ .name = HHSTR(valloc(VFS_NAME_MAXLEN), 0, 0) };
+      (struct v_xattr_entry){ .name = HHSTR(valloc(VFS_NAME_MAXLEN), 0, 0),
+                              .value = NULL };
 
     hstrcpy(&entry->name, name);
     return entry;
@@ -20,7 +23,7 @@ xattr_new(struct hstr* name)
 void
 xattr_free(struct v_xattr_entry* entry)
 {
-    vfree(entry->name.value);
+    vfree((void*)entry->name.value);
     vfree(entry);
 }