Esempio n. 1
0
void StringBuffer::absorb(StringBuffer &buf) {
  if (empty()) {
    TAINT_OBSERVER_REGISTER_ACCESSED(buf.getTaintDataRefConst());
    TAINT_OBSERVER_REGISTER_MUTATED(m_taint_data, dataIgnoreTaint());

    StringData* str = m_str;

    m_str = buf.m_str;
    m_buffer = buf.m_buffer;
    m_len = buf.m_len;
    m_cap = buf.m_cap;

    buf.m_str = str;
    if (str) {
      buf.m_buffer = (char*)str->data();
      buf.m_len = str->size();
      buf.m_cap = str->capacity();
    } else {
      buf.m_buffer = 0;
      buf.m_len = 0;
      buf.m_cap = 0;
    }
    buf.reset();
  } else {
    // REGISTER_ACCESSED()/REGISTER_MUTATED() are called by append()/detach()
    append(buf.detach());
  }
}
Esempio n. 2
0
const char *StringBuffer::data() const {
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);
  if (m_buffer && m_len) {
    m_buffer[m_len] = '\0'; // fixup
    return m_buffer;
  }
  return NULL;
}
Esempio n. 3
0
String CstrBuffer::detach() {
  ASSERT(m_len <= m_cap);
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);
  m_buffer[m_len] = 0;
  String s(m_buffer, m_len, AttachString);
  m_buffer = 0;
  m_len = m_cap = 0;
  return s;
}
Esempio n. 4
0
String StringBuffer::detachImpl() {
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);
#ifdef TAINTED
  m_taint_data.unsetTaint(TAINT_BIT_ALL);
#endif

  if (m_buffer && m_pos) {
    m_buffer[m_pos] = '\0'; // fixup
    String ret(m_buffer, m_pos, AttachString);
    m_buffer = NULL;
    m_pos = 0;
    return ret;
  }
  return String("");
}
Esempio n. 5
0
char *StringBuffer::detach(int &size) {
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);
#ifdef TAINTED
  m_taint_data.unsetTaint(TAINT_BIT_ALL);
#endif
  if (m_buffer) {
    if (m_pos) {
      m_buffer[m_pos] = '\0'; // fixup
      size = m_pos;
      char *ret = m_buffer;
      m_buffer = NULL;
      m_pos = 0;
      return ret;
    }
    size = 0;
  }
  return NULL;
}
Esempio n. 6
0
String StringBuffer::detachImpl() {
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);
#ifdef TAINTED
  m_taint_data.unsetTaint(TAINT_BIT_ALL);
#endif

  if (m_buffer && m_len) {
    ASSERT(m_str && m_str->getCount() == 0);
    m_buffer[m_len] = '\0'; // fixup
    StringData* str = m_str;
    str->setSize(m_len);
    m_str = 0;
    m_buffer = 0;
    m_len = 0;
    m_cap = 0;
    return String(str); // causes incref
  }
  return String("");
}
void StringBuffer::absorb(StringBuffer &buf) {
  if (empty()) {
    TAINT_OBSERVER_REGISTER_ACCESSED(buf.getTaintDataRefConst());
    TAINT_OBSERVER_REGISTER_MUTATED(m_taint_data);

    char *buffer = m_buffer;
    int size = m_size;

    m_buffer = buf.m_buffer;
    m_size = buf.m_size;
    m_pos = buf.m_pos;

    buf.m_buffer = buffer;
    buf.m_size = size;
    buf.reset();
  } else {
    append(buf.detach());
  }
}
String StringBuffer::copy() {
  TAINT_OBSERVER_REGISTER_ACCESSED(m_taint_data);

  String r = String(data(), size(), CopyString);
  return r;
}