Помогите пожалуйста не могу найти где выходит за область памяти.
/*
#include "/usr/include/dirent.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include "/usr/include/sys/types.h"
#include "/usr/include/sys/stat.h"
int dir_info(char * dirpath);
int main(int argc, char * argv[]) {
errno = 0;
dir_info(argv[0]);
return 0;
}
int is_executable(struct dirent *e) {
struct stat st;
lstat(e->d_name, &st);
if ((st.st_mode & S_IXUSR) || (st.st_mode & S_IXGRP) || (st.st_mode & S_IXOTH))
return (int)st.st_size;
return 0;
}
int dir_info(char * dirpath) {
DIR * dir = opendir(dirpath);
errno = 0;
if (dir) {
perror("opendir ");
return -1;
};
struct dirent* current = readdir(dir);
while (current != NULL) {
if (current->d_type == DT_DIR) {
char * name_dir = current->d_name;
int file_count = 0;
int file_executable_count = 0;
int files_size = 0;
int filesize = 0;
DIR * dirp;
struct dirent * entry;
dirp = opendir(name_dir);
while ((entry = readdir(dirp)) != NULL) {
if (entry->d_type == DT_REG) {
file_count++;
if ((filesize = is_executable(entry)) != 0)
files_size += filesize;
file_executable_count++;
}
}
closedir(dirp);
//fprintf("dir_name: %d - count_files: %d - count executable files: %d - size files: %d",
// name_dir , file_count, file_executable_count, files_size);
printf(name_dir);
}
printf("Hell");
}
return 0;
}