Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
segfaulting or handling errors the same way themselves.
diff --git a/ar.c b/ar.c
index d82763d..241c1fa 100644
--- a/ar.c
+++ b/ar.c
@@ -246,7 +246,7 @@
headerL_t *list;
off_t initialOffset;
- list = (headerL_t *) malloc(sizeof(headerL_t));
+ list = (headerL_t *) xmalloc(sizeof(headerL_t));
initialOffset=lseek(srcFd, 0, SEEK_CUR);
if (checkArMagic(srcFd)==TRUE)
ar=TRUE;
@@ -258,7 +258,7 @@
if (tar==TRUE) {
while(readTarHeader(srcFd, list)==TRUE) {
off_t tarOffset;
- list->next = (headerL_t *) malloc(sizeof(headerL_t));
+ list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
@@ -282,7 +282,7 @@
if (readArEntry(srcFd, list) == FALSE)
return(head);
}
- list->next = (headerL_t *) malloc(sizeof(headerL_t));
+ list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
@@ -349,9 +349,9 @@
return (FALSE);
}
optind++;
- entry = (headerL_t *) malloc(sizeof(headerL_t));
- header = (headerL_t *) malloc(sizeof(headerL_t));
- extractList = (headerL_t *) malloc(sizeof(headerL_t));
+ entry = (headerL_t *) xmalloc(sizeof(headerL_t));
+ header = (headerL_t *) xmalloc(sizeof(headerL_t));
+ extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
header = getHeaders(srcFd, header, funct);
/* find files to extract or display */
@@ -359,7 +359,7 @@
/* only handle specified files */
while(optind < argc) {
if ( (entry = findEntry(header, argv[optind])) != NULL) {
- entry->next = (headerL_t *) malloc(sizeof(headerL_t));
+ entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*entry->next = *extractList;
*extractList = *entry;
}