Skip to content

Commit

Permalink
Merge branch 'cubicdaiya-alloc-error-handling'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Apr 15, 2015
2 parents 5c2ca28 + 59f8397 commit 53bcafb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/comp_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ json_t *dump_header(const uint8_t *name, size_t namelen, const uint8_t *value,
size_t valuelen) {
json_t *nv_pair = json_object();
char *cname = malloc(namelen + 1);
if (cname == NULL) {
return NULL;
}
memcpy(cname, name, namelen);
cname[namelen] = '\0';
json_object_set_new(nv_pair, cname, json_pack("s#", value, valuelen));
Expand Down
6 changes: 6 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,16 @@ char *get_exec_path(int argc, char **const argv, const char *cwd) {

if (argv0[0] == '/') {
path = static_cast<char *>(malloc(len + 1));
if (path == nullptr) {
return nullptr;
}
memcpy(path, argv0, len + 1);
} else {
auto cwdlen = strlen(cwd);
path = static_cast<char *>(malloc(len + 1 + cwdlen + 1));
if (path == nullptr) {
return nullptr;
}
memcpy(path, cwd, cwdlen);
path[cwdlen] = '/';
memcpy(path + cwdlen + 1, argv0, len + 1);
Expand Down

0 comments on commit 53bcafb

Please sign in to comment.