I'm coding this CGI program in C and seem to be having some memory violations. Intially i coded it and the code returned a char *, however when i asked in main to print the value there with puts. my code crashed, however i could do so with printf.

In order to have it work better, i coded it again, and now this time my code seems to just crashes. I have no idea where the seg fault is as i've been staring at it for a while. Please let me know if you need to see the additional functions. However they seem to work fine, as this was the only code i changed.

Code:
#include <stdio.h>
#include <stdlib.h> // for getenv. don't implicitly call this function
#include <string.h>
#include "CGINCform.h"

char *getvalue(char *name){
if( (getenv("REQUEST_METHOD")) =="post"){
	 /*length of info from stdin,buffer for url, temp and return value of nameValue()*/
	 char *formLength;
	 char *url;
	 char *Temp;
	 char *ValueOfName;
	 unsigned long INPUT;/*size of input from stdin*/
	 
	 /*get form length and convert to a number.*/
	 formLength = getenv("CONTENT_LENGTH");
    INPUT = atol(formLength);
    
    /*make sure room available on system to store info from stdin*/
    if ((url = malloc( (INPUT+1) * sizeof(char) ) ) == NULL){
   perror("No room Allocated for url");
   return NULL;
   }
   
    if ((Temp = malloc((INPUT+1) * sizeof (char) ) ) == NULL){
   perror("No room allocated for Temp");
   return NULL;
   }

  /*get info from stdin and store accordingly */
   
   if( ( fgets(url,INPUT,stdin) ) !=NULL){
   decodeUrl(url); 
   hex2Dec(Temp,url); /*copies url to temp and transforms it */
   /*look for the value of name in temp which is up to INPUT and returns its address*/
   ValueOfName=nameValue(Temp,INPUT,name);
   free(url);/*isn't used anymore copied into temp by hex2Dec*/
   //free(Temp);
   }/*end of info processing info from STDIN */

return ValueOfName;	 
}/*end of 1st if block and succesful input from stdin */

else 

return NULL;/*no  valid HTTP method given end of if branch */

}/*end of function getvalue.c */