boutell / cgic

cgic: an ANSI C library for CGI Programming
Other
249 stars 96 forks source link

warning: attempt to free a non-heap object 'cgiContentTypeData' #15

Closed andrei-aciobanitei closed 4 years ago

andrei-aciobanitei commented 4 years ago

Hello,

Is there a specific reason why free(cgiContentType) is called for a statically allocated variable?

char cgiContentTypeData[1024];
char *cgiContentType = cgiContentTypeData;

Thank you.

boutell commented 4 years ago

Closing but let me know if I missed something. Thanks for getting in touch

boutell commented 4 years ago

It's not freed all the time, only when the CGI state was restored from a file, in which case it is allocated from the heap, not static.

On Fri, Aug 7, 2020 at 9:02 AM mcssm notifications@github.com wrote:

Hello,

Is there a specific reason why free(cgiContentType) is called for a statically allocated variable?

char cgiContentTypeData[1024]; char *cgiContentType = cgiContentTypeData;

Thank you.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/boutell/cgic/issues/15, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27OTDKZRD376U6XT2Q3R7P3PVANCNFSM4PXTPCSA .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his

andrei-aciobanitei commented 4 years ago

Thank you for your quick reply. Yes, indeed, it is freed only when allocated from the heap (when cgiRestored is set to 1).