Permalink
Browse files

the new getoutputformatOption should strdup values to avoid double-frees

  • Loading branch information...
1 parent 7c8ffaa commit 4a440bdabbc55ebebbb40ab8ddb04c235901f345 @unicolet unicolet committed Feb 2, 2013
Showing with 3 additions and 5 deletions.
  1. +1 −1 mapscript/java/examples/OutputFormatList.java
  2. +2 −4 mapscript/swiginc/outputformat.i
@@ -21,7 +21,7 @@ public static void main(String[] args) {
outputFormatObj format = map.getOutputFormat(i);
System.out.println("["+i+"] Format name: "+format.getName());
System.out.println("\toption count: "+format.getNumformatoptions());
- for(int j=0;j<format.getNumformatoptions();i++) {
+ for(int j=0;j<format.getNumformatoptions();j++) {
System.out.println("\t["+j+"] option: "+format.getOptionAt(j));
}
}
@@ -87,15 +87,13 @@
%newobject getOption;
char *getOption(const char *key, const char *value="")
{
- const char *retval;
- retval = msGetOutputFormatOption(self, key, value);
- return retval;
+ return strdup(msGetOutputFormatOption(self, key, value));
}
%newobject getOptionAt;
char* getOptionAt(int i) {
if( i >= 0 && i < self->numformatoptions ) {
- return self->formatoptions[i];
+ return strdup(self->formatoptions[i]);
}
return NULL;
}

0 comments on commit 4a440bd

Please sign in to comment.