mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
fd: fix table cloning
This commit is contained in:
+7
-1
@@ -114,12 +114,18 @@ int fd_tableclone(fdtable_t* source, fdtable_t* dest){
|
||||
|
||||
spinlock_acquire(&source->lock);
|
||||
|
||||
if(fd_tableinit(dest)){
|
||||
spinlock_release(&source->lock);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if(source->fdcount != dest->fdcount){
|
||||
void* tmp = alloc(source->fdcount*sizeof(fd_t*));
|
||||
void* tmp = realloc(dest->fd, source->fdcount*sizeof(fd_t*));
|
||||
if(!tmp){
|
||||
spinlock_release(&source->lock);
|
||||
return ENOMEM;
|
||||
}
|
||||
dest->fd = tmp;
|
||||
dest->fdcount = source->fdcount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user