Author: Ole Streicher <debian@liska.ath.cx>
Description: Fix some bugs in fitsCmds.c:
  * In fitsTcl_get(), the header is allocated by ffhdr2str(), but is freed by
    ckfree(). This causes crashes if ckfree() is not just a free() alias.
  * Fix some variable declarations and type casts to match prototypes.
  * Check the number of arguments in "get translatedKeywords".
  * Fix status parameter in exxor handling of fits_copy_cell2image() of
    "get translatedKeywords".
--- a/fitsCmds.c
+++ b/fitsCmds.c
@@ -360,7 +360,7 @@
    
    } else if( !strcmp("filesize",argv[2]) ) {
 
-      sprintf(result,"%ld",curFile->fptr->Fptr->filesize/2880);
+      sprintf(result,"%lld",curFile->fptr->Fptr->filesize/2880);
       Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
 
    } else if( !strcmp("hdutype",argv[2]) ) {
@@ -976,8 +976,8 @@
       int naxis = 2;
       long naxes[2];
       int columns[FITS_MAXDIMS];
-      int *nkeys;
-      char **header;
+      int nkeys;
+      char *header;
       int i,j;
 
       /* Pan Chai: there is only 2 columns */
@@ -1032,7 +1032,7 @@
       }
 
       status = 0;
-      if ( ffhdr2str(dummyptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
+      if ( ffhdr2str(dummyptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
 	 Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
 	 return TCL_ERROR;
       }
@@ -1049,7 +1049,7 @@
       Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewListObj(5,data) );
       Tcl_SetObjResult(curFile->interp, listObj);
 
-      ckfree( (char*) header);
+      free( header);
       return TCL_OK;
  
    } else if( !strcmp("translatedKeywords", argv[2]) ) {
@@ -1058,6 +1058,13 @@
       long rownum;
       fitsfile *newptr;
 
+      if ( argc != 5 ) {
+	  Tcl_SetResult(curFile->interp,
+			"Usage: get translatedKeywords rownum colname",
+			TCL_STATIC);
+	  return TCL_ERROR;
+      }
+
       strcpy(outfile, "mem://_1");
 
       /* Copy the image into new primary array and open it as the current */
@@ -1075,13 +1082,14 @@
       status = 0;
       if (fits_copy_cell2image(curFile->fptr, newptr, argv[3], rownum, &status) > 0) 
       {
+	  int status2 = 0;
           ffpmsg("Failed to copy table cell to new primary array:");
-          ffclos(curFile->fptr, status);
+          ffclos(curFile->fptr, &status2);
           curFile->fptr = 0;              /* return null file pointer */
           return(status);
       }
 
-      if ( ffhdr2str(newptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
+      if ( ffhdr2str(newptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
 	 Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
 	 return TCL_ERROR;
       }
@@ -1102,7 +1110,7 @@
       Tcl_SetObjResult(curFile->interp, listObj);
 */
 
-      ckfree( (char*) header);
+      free( header);
       return TCL_OK;
  
    } else if( !strcmp("header2str", argv[2]) ) {
@@ -1114,7 +1122,7 @@
      /*                int *nkeys,         O - returned number of 80-char keywords  */
      /*                int  *status)       IO - error status                        */
 
-      if ( ffhdr2str(curFile->fptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
+      if ( ffhdr2str(curFile->fptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
 	 Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
 	 return TCL_ERROR;
       }
@@ -1123,7 +1131,7 @@
       Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewIntObj( nkeys ) );
       Tcl_SetObjResult(curFile->interp, listObj);
 
-      ckfree( (char*) header);
+      free( header);
       return TCL_OK;
  
    } else if( !strcmp("imgwcs", argv[2]) ) {
