Ben Franksen wrote:
>         /*
>           The maximum length of a file element
>         */
>         long ln=MAX_FILE_LENGTH;
>         char * narrow_dir_string = wcs2str(dir_string);
> 
>         /*
>           In recursive mode, we look through the directory twice. If
>           so, this rewind is needed.
>         */
>         rewinddir(dir);
> 
>         if (narrow_dir_string)
>         {
>             /*
>                Find out how long the filename can be in a worst case
>                scenario
>             */
>             ln = pathconf(narrow_dir_string, _PC_NAME_MAX);
> 
>             /*
>               If not specified, use som large number as fallback
>             */
>             if (ln < 0)
>                 ln = MAX_FILE_LENGTH;
>             free(narrow_dir_string);
>         }
>         fprintf(stderr, "malloc_arg=%lu\n", 
> sizeof(wchar_t)*(base_len+ln+2));
>         new_dir= (wchar_t *)malloc(sizeof(wchar_t)*(base_len+ln+2));
> 
> 
> where I added the printf before the malloc call. This is what I get 
> immediately before the crash:
> 
> ben@sarun ~> cd ctl/toonarrow_dir_string=0x7fd5140072a0
> malloc_arg=1028
> malloc_arg=8589934612
> 
> So you try to allocate a ridiculous amount of memory which fails of 
course.
> 
> This is probably due to using MAX_FILE_LENGTH as the default for 'ln'; I 
> guess you want something a bit saner here... ;-)

Stupid me, the MAX_FILE_LENGTH is defined as 1024 which is fine. The problem 
is that the call to pathconf returns 2147483647.

Cheers
-- 
Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachm€nts


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to