[LAD] C - Change in memory causing seg.fault (but why?)

Brett McCoy idragosani at gmail.com
Thu Nov 8 21:02:27 UTC 2012


On Thu, Nov 8, 2012 at 3:42 PM, Muffinman <news at koster.tk> wrote:

> I'm working on a little app utilizing 'lasound' and I've got bassically
> what I want. However, somewhere there is a fault. Editing a random
> variable causes a segmentation fault. I've tried gdb but except it
> telling me where the application crashed (which I already knew) I did
> not get anything useful out of it. To minimize my own potential errors I
> have here below the example script from where I started (though I have
> removed some unnecessary stuff) and commented out the 'long *outvl' and
> '*outvl = -1'. Uncommenting, compile, and run this and I get a
> segmentation fault.

You never allocate memory for the pointer long *outvl after you create
it, but then try to point to a value. You need to use malloc() to
initialize the memory for that pointer before you can use it.

-- 
Brett W. McCoy -- http://www.brettwmccoy.com
------------------------------------------------------------------------
"In the rhythm of music a secret is hidden; If I were to divulge it,
it would overturn the world."
    -- Jelaleddin Rumi



More information about the Linux-audio-dev mailing list