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

From: Brett McCoy <idragosani@email-addr-hidden>
Date: Thu Nov 08 2012 - 23:02:27 EET

On Thu, Nov 8, 2012 at 3:42 PM, Muffinman <news@email-addr-hidden> 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
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri Nov 9 00:15:02 2012

This archive was generated by hypermail 2.1.8 : Fri Nov 09 2012 - 00:15:02 EET