[505] in BarnOwl Developers
[D-O-H] r626 - trunk/owl
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:06:53 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@MIT.EDU
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Fri, 23 Feb 2007 15:12:50 -0500 (EST)
Author: asedeno
Date: 2007-02-23 15:12:49 -0500 (Fri, 23 Feb 2007)
New Revision: 626
Modified:
trunk/owl/functions.c
trunk/owl/util.c
Log:
Fixing a bug reported over zephyr in which narrowing would permanently
break replies due to in-place string manipulation.
owl_util_baseclass now returns a new string, which must be freed by
the caller.
Modified: trunk/owl/functions.c
===================================================================
--- trunk/owl/functions.c 2007-02-20 00:05:36 UTC (rev 625)
+++ trunk/owl/functions.c 2007-02-23 20:12:49 UTC (rev 626)
@@ -2676,6 +2676,10 @@
owl_global_add_filter(&g, f);
owl_free(argbuff);
+ owl_free(class);
+ if (instance) {
+ owl_free(instance);
+ }
return(filtname);
}
Modified: trunk/owl/util.c
===================================================================
--- trunk/owl/util.c 2007-02-20 00:05:36 UTC (rev 625)
+++ trunk/owl/util.c 2007-02-23 20:12:49 UTC (rev 626)
@@ -738,20 +738,22 @@
/* Return the base class or instance from a zephyr class, by removing
leading `un' or trailing `.d'.
- Modified ``class'' in place, and does not allocate memory.
+ The caller is responsible for freeing the allocated string.
*/
char * owl_util_baseclass(char * class)
{
+ char * newClass;
char * end;
- while(!strncmp(class, "un", 2)) {
- class += 2;
+ newClass = owl_strdup(class);
+ while(!strncmp(newClass, "un", 2)) {
+ newClass += 2;
}
- end = class + strlen(class) - 1;
+ end = newClass + strlen(newClass) - 1;
while(*end == 'd' && *(end-1) == '.') {
end -= 2;
}
*(end + 1) = 0;
- return class;
+ return newClass;
}
/**************************************************************************/