~ubuntu-branches/debian/stretch/tcl-fitstcl/stretch

« back to all changes in this revision

Viewing changes to debian/patches/fix_fitsCmds.patch

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2015-06-10 17:35:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150610173543-37jifpt0bjuocrr0
Tags: 2.4-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Author: Ole Streicher <debian@liska.ath.cx>
2
 
Description: Fix some bugs in fitsCmds.c:
3
 
  * In fitsTcl_get(), the header is allocated by ffhdr2str(), but is freed by
4
 
    ckfree(). This causes crashes if ckfree() is not just a free() alias.
5
 
  * Fix some variable declarations and type casts to match prototypes.
6
 
  * Check the number of arguments in "get translatedKeywords".
7
 
  * Fix status parameter in exxor handling of fits_copy_cell2image() of
8
 
    "get translatedKeywords".
9
 
--- a/fitsCmds.c
10
 
+++ b/fitsCmds.c
11
 
@@ -360,7 +360,7 @@
12
 
    
13
 
    } else if( !strcmp("filesize",argv[2]) ) {
14
 
 
15
 
-      sprintf(result,"%ld",curFile->fptr->Fptr->filesize/2880);
16
 
+      sprintf(result,"%lld",curFile->fptr->Fptr->filesize/2880);
17
 
       Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
18
 
 
19
 
    } else if( !strcmp("hdutype",argv[2]) ) {
20
 
@@ -976,8 +976,8 @@
21
 
       int naxis = 2;
22
 
       long naxes[2];
23
 
       int columns[FITS_MAXDIMS];
24
 
-      int *nkeys;
25
 
-      char **header;
26
 
+      int nkeys;
27
 
+      char *header;
28
 
       int i,j;
29
 
 
30
 
       /* Pan Chai: there is only 2 columns */
31
 
@@ -1032,7 +1032,7 @@
32
 
       }
33
 
 
34
 
       status = 0;
35
 
-      if ( ffhdr2str(dummyptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
36
 
+      if ( ffhdr2str(dummyptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
37
 
         Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
38
 
         return TCL_ERROR;
39
 
       }
40
 
@@ -1049,7 +1049,7 @@
41
 
       Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewListObj(5,data) );
42
 
       Tcl_SetObjResult(curFile->interp, listObj);
43
 
 
44
 
-      ckfree( (char*) header);
45
 
+      free( header);
46
 
       return TCL_OK;
47
 
  
48
 
    } else if( !strcmp("translatedKeywords", argv[2]) ) {
49
 
@@ -1058,6 +1058,13 @@
50
 
       long rownum;
51
 
       fitsfile *newptr;
52
 
 
53
 
+      if ( argc != 5 ) {
54
 
+         Tcl_SetResult(curFile->interp,
55
 
+                       "Usage: get translatedKeywords rownum colname",
56
 
+                       TCL_STATIC);
57
 
+         return TCL_ERROR;
58
 
+      }
59
 
+
60
 
       strcpy(outfile, "mem://_1");
61
 
 
62
 
       /* Copy the image into new primary array and open it as the current */
63
 
@@ -1075,13 +1082,14 @@
64
 
       status = 0;
65
 
       if (fits_copy_cell2image(curFile->fptr, newptr, argv[3], rownum, &status) > 0) 
66
 
       {
67
 
+         int status2 = 0;
68
 
           ffpmsg("Failed to copy table cell to new primary array:");
69
 
-          ffclos(curFile->fptr, status);
70
 
+          ffclos(curFile->fptr, &status2);
71
 
           curFile->fptr = 0;              /* return null file pointer */
72
 
           return(status);
73
 
       }
74
 
 
75
 
-      if ( ffhdr2str(newptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
76
 
+      if ( ffhdr2str(newptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
77
 
         Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
78
 
         return TCL_ERROR;
79
 
       }
80
 
@@ -1102,7 +1110,7 @@
81
 
       Tcl_SetObjResult(curFile->interp, listObj);
82
 
 */
83
 
 
84
 
-      ckfree( (char*) header);
85
 
+      free( header);
86
 
       return TCL_OK;
87
 
  
88
 
    } else if( !strcmp("header2str", argv[2]) ) {
89
 
@@ -1114,7 +1122,7 @@
90
 
      /*                int *nkeys,         O - returned number of 80-char keywords  */
91
 
      /*                int  *status)       IO - error status                        */
92
 
 
93
 
-      if ( ffhdr2str(curFile->fptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
94
 
+      if ( ffhdr2str(curFile->fptr, 1, (char **)NULL, 0, &header, &nkeys, &status) > 0 ) {
95
 
         Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
96
 
         return TCL_ERROR;
97
 
       }
98
 
@@ -1123,7 +1131,7 @@
99
 
       Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewIntObj( nkeys ) );
100
 
       Tcl_SetObjResult(curFile->interp, listObj);
101
 
 
102
 
-      ckfree( (char*) header);
103
 
+      free( header);
104
 
       return TCL_OK;
105
 
  
106
 
    } else if( !strcmp("imgwcs", argv[2]) ) {