Further cleanup-code/less "optimistic" assumptions. (#12298)

This commit is contained in:
David CARLIER 2018-11-23 22:18:40 +00:00 committed by radare
parent 356ff9a7ff
commit c504572cfa
3 changed files with 20 additions and 5 deletions

View File

@ -219,8 +219,18 @@ R_API R2Pipe *r2p_open(const char *cmd) {
w32_createPipe (r2p, cmd);
r2p->child = (int)(r2p->pipe);
#else
pipe (r2p->input);
pipe (r2p->output);
int r = pipe (r2p->input);
if (r != 0) {
eprintf ("pipe failed on input\n");
r2p_close (r2p);
return NULL;
}
r = pipe (r2p->output);
if (r != 0) {
eprintf ("pipe failed on output\n");
r2p_close (r2p);
return NULL;
}
#if LIBC_HAVE_FORK
r2p->child = fork ();
#else

View File

@ -61,10 +61,15 @@ R_API bool r_file_truncate (const char *filename, ut64 newsize) {
return false;
}
#ifdef _MSC_VER
_chsize (fd, newsize);
int r = _chsize (fd, newsize);
#else
ftruncate (fd, newsize);
int r = ftruncate (fd, newsize);
#endif
if (r != 0) {
eprintf ("Coult not resize %s file\n", filename);
close (fd);
return false;
}
close (fd);
return true;
}

View File

@ -185,7 +185,7 @@ R_API void r_rbtree_aug_insert(RBNode **root, void *data, RBNode *node, RBCompar
return;
}
RBNode *t = NULL, *g = NULL, *p = NULL, *q = *root;
int d, dep = 0;
int d = 0, dep = 0;
bool done = false;
RBNode *path[R_RBTREE_MAX_HEIGHT];
for (;;) {