#valgrind error help

42 messages ยท Page 1 of 1 (latest)

shrewd chasmBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

plain lava
#

code:

#

this is the outFile function where the error is

#

(which is called from main)

true canopy
#

you just censored the outFile and main information ๐Ÿ˜‘

true canopy
#

nevertheless my bet are these two lines

        buffer[strcspn(buffer, "\r\n")] = 0;
        tokens = strtok(buffer, " , ");
plain lava
#

its just a address to the c file

true canopy
#

the addresses are on the left, the details are what the ones you censored

plain lava
#

i mean the path mb

true canopy
#

they have line numbers for the calls that cause the issue zzz๐Ÿ˜‘

plain lava
#

nop

true canopy
#

good luck then

plain lava
#

huh

#

they genuinely dont have line numbers lol

#

:(

plain lava
#

if anyone finds a solution an @ would be great

obsidian island
#

This
nevertheless my bet are these two lines

        buffer[strcspn(buffer, "\r\n")] = 0;
        tokens = strtok(buffer, " , ");

Is sus af, investigate it

obsidian island
#

Well read the man page of strcspn

plain lava
#

if i were to remove that line would you expect that error to be gone?

obsidian island
#

And think of how you imagine it behaves when you're telling strcspn to search the buffer that you're currently declaring using strcspn's return value

#

Don't just throw spaghetti at the wall. Read the description of strcspn and think about the code (well, the first line of those mentioned)

#

Wait i'm le stupid

#

It's not a declaration, sorry

#

It's just an assignment.

plain lava
#

well I removed that line and it still gives me the same error

#

so i feel its not something to do with strcspn

obsidian island
#

That approach is not informative. Removing a line arbitrarily might have effects that don't even relate to the error

#

Why do you call strtok() with NULL as its 1st argument on a line further down?

#

What do you imagine it does?

plain lava
#

it gets the next token

#

e.g if i have 124124,foo,bar it will get 124124 then foo then bar each time i call it

obsidian island
#

Right, I didn't know. Manpage says that too

barren galleon
#

looks like to me you are returning a pointer to stack memory from some function

plain lava
#

i thought it couldnt be because its not listed in the valgrind list

#

although that only returns an integer?

plain lava
#

it must be from the fact that

#

i am storing the ID in a array of strings (which is on the stack i assume?)