Changeset 89e780d in mainline


Ignore:
Timestamp:
2011-02-25T18:08:20Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
27833d8, 5ca5eaa7
Parents:
9fec913
Message:

Use the correct size of the allocated buffer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    r9fec913 r89e780d  
    6969        char *ncwd_path;
    7070        char *ncwd_path_nc;
     71        size_t total_size;
    7172
    7273        fibril_mutex_lock(&cwd_mutex);
     
    7778                        return NULL;
    7879                }
    79                 ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
     80                total_size = cwd_size + 1 + size + 1;
     81                ncwd_path_nc = malloc(total_size);
    8082                if (!ncwd_path_nc) {
    8183                        fibril_mutex_unlock(&cwd_mutex);
    8284                        return NULL;
    8385                }
    84                 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);
     86                str_cpy(ncwd_path_nc, total_size, cwd_path);
    8587                ncwd_path_nc[cwd_size] = '/';
    8688                ncwd_path_nc[cwd_size + 1] = '\0';
    8789        } else {
    88                 ncwd_path_nc = malloc(size + 1);
     90                total_size = size + 1;
     91                ncwd_path_nc = malloc(total_size);
    8992                if (!ncwd_path_nc) {
    9093                        fibril_mutex_unlock(&cwd_mutex);
     
    9396                ncwd_path_nc[0] = '\0';
    9497        }
    95         str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);
     98        str_append(ncwd_path_nc, total_size, path);
    9699        ncwd_path = canonify(ncwd_path_nc, retlen);
    97100        if (!ncwd_path) {
Note: See TracChangeset for help on using the changeset viewer.