Permalink
Browse files

add a ugly hack so m0 won't be segfault when free chunk name constants

  • Loading branch information...
1 parent ab32a83 commit 8db2a148b198939f06d5f2ca1e25db5e5b07500a Jimmy Zhuo committed Jun 3, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/m0/c/m0_mob.c
View
@@ -229,7 +229,11 @@ parse_mob_constants_segment( M0_Interp *interp, FILE *stream ) {
if (length > 8) {
int encoding = *(long *)&(constant[4]);
if (encoding == 0) {
- constant = (char *) &(constant[8]);
+ const unsigned long str_length = length - 9;
+ char *p = malloc(str_length);
+ memcpy(p, &constant[8], str_length);
+ free(constant);
+ constant = p;
}
if (constant) {
segment->consts[i] = (uint64_t)constant;

0 comments on commit 8db2a14

Please sign in to comment.