Loading ...
Sorry, an error occurred while loading the content.

Re: libcall()

Expand Messages
  • Johannes Zellner
    Neil, I tried ... and got a SEGFAULT in eval.c:4688 for (p = get_var_string(&retvar); *p != NUL && !got_int; ++p) I guess this is due to the fact that the
    Message 1 of 38 , Feb 23, 2000
    • 0 Attachment
      Neil,

      I tried
      :echo libcall("/lib/libc.so.6", "printf", "hello")
      and got a SEGFAULT in
      eval.c:4688
      for (p = get_var_string(&retvar); *p != NUL && !got_int; ++p)

      I guess this is due to the fact that the result is interpreted
      as string (char*) but is an integer (5). How would you catch
      a misusage like this ?

      --
      Johannes
    • Bram Moolenaar
      ... Yes, but it uses alloc() (a Vim function) instead of malloc(). alloc() has a few extra checks for not allocating too much memory (so that enough is left
      Message 38 of 38 , Mar 12 8:12 AM
      • 0 Attachment
        Wichert Akkerman wrote:
        > Previously Bram Moolenaar wrote:
        > > No, vim_strsave() is just a wrapper around malloc(), used to make a copy
        > > of a string.
        >
        > So it's basically strdup?

        Yes, but it uses alloc() (a Vim function) instead of malloc(). alloc() has a
        few extra checks for not allocating too much memory (so that enough is left to
        write out the file when needed, for example).

        --
        hundred-and-one symptoms of being an internet addict:
        147. You finally give up smoking...because it made the monitor dirty.

        /-/-- Bram Moolenaar --- Bram@... --- http://www.moolenaar.net --\-\
        \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
      Your message has been successfully submitted and would be delivered to recipients shortly.