Permalink
Browse files

Use LocalBuffer to free the buffer at any exit point of Float::from_cstr

  • Loading branch information...
1 parent 413fbbe commit 23ab7e926dc3be44c99d102adcbae8787828a7f2 @zaeleus committed Apr 12, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 vm/builtin/float.cpp
View
@@ -21,6 +21,8 @@
#include "missing/math.h"
+#include "util/local_buffer.hpp"
+
namespace rubinius {
void Float::init(STATE) {
@@ -85,7 +87,8 @@ namespace rubinius {
str++;
}
- char* buffer = (char*)malloc(strlen(str) + 1);
+ LocalBuffer b(strlen(str) + 1);
+ char* buffer = (char*)b.buffer;
char* p = buffer;
char prev = '\0';
@@ -190,8 +193,6 @@ namespace rubinius {
}
}
- free(buffer);
-
return Float::create(state, value);
}

0 comments on commit 23ab7e9

Please sign in to comment.