mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
uppsrc: asan and ubsan fixes
This commit is contained in:
parent
5a208e3822
commit
9e33f8fb66
11 changed files with 37 additions and 27 deletions
|
|
@ -53,8 +53,10 @@ void PackedData::SetData(int ii, const void *data, int datalen)
|
|||
};
|
||||
auto Out = [&](const void *s, int len) {
|
||||
Reserve(len);
|
||||
memcpy(t, s, len);
|
||||
t += len;
|
||||
if(len) {
|
||||
memcpy(t, s, len);
|
||||
t += len;
|
||||
}
|
||||
};
|
||||
int i = 0;
|
||||
const byte *p = (const byte *)ptr;
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ public:
|
|||
byte *PutPtr(int size = 1) { ASSERT(size > 0); if(ptr + size <= wrlim) { byte *p = ptr; ptr += size; return p; }; return NULL; }
|
||||
const byte *GetSzPtr(int& size) { Term(); size = int(rdlim - ptr); byte *p = ptr; ptr += size; return p; }
|
||||
|
||||
void Put(const void *data, int size) { ASSERT(size >= 0); if(size) { if(ptr + size <= wrlim) { memcpy8(ptr, data, size); ptr += size; } else _Put(data, size); } }
|
||||
int Get(void *data, int size) { ASSERT(size >= 0); if(ptr + size <= rdlim) { memcpy8(data, ptr, size); ptr += size; return size; } return _Get(data, size); }
|
||||
void Put(const void *data, int size) { ASSERT(size >= 0); if(size) { if(ptr && ptr + size <= wrlim) { memcpy8(ptr, data, size); ptr += size; } else _Put(data, size); } }
|
||||
int Get(void *data, int size) { ASSERT(size >= 0); if(ptr && ptr + size <= rdlim) { memcpy8(data, ptr, size); ptr += size; return size; } return _Get(data, size); }
|
||||
|
||||
void Put(const String& s) { Put((const char *) s, s.GetLength()); }
|
||||
String Get(int size);
|
||||
|
|
|
|||
|
|
@ -550,7 +550,8 @@ template <class T>
|
|||
void Array<T>::SetCount(int n) {
|
||||
ASSERT(n >= 0);
|
||||
int lc = vector.GetCount();
|
||||
Del(vector.begin() + n, vector.end());
|
||||
if(n < lc)
|
||||
Del(vector.begin() + n, vector.end());
|
||||
vector.SetCount(n);
|
||||
Init(vector.begin() + lc, vector.begin() + n);
|
||||
}
|
||||
|
|
@ -559,7 +560,8 @@ template <class T>
|
|||
void Array<T>::SetCount(int n, const T& init) {
|
||||
ASSERT(n >= 0);
|
||||
int lc = vector.GetCount();
|
||||
Del(vector.begin() + n, vector.end());
|
||||
if(n < lc)
|
||||
Del(vector.begin() + n, vector.end());
|
||||
vector.SetCount(n);
|
||||
Init(vector.begin() + lc, vector.begin() + n, init);
|
||||
}
|
||||
|
|
@ -568,7 +570,8 @@ template <class T>
|
|||
void Array<T>::SetCountR(int n) {
|
||||
ASSERT(n >= 0);
|
||||
int lc = vector.GetCount();
|
||||
Del(vector.begin() + n, vector.end());
|
||||
if(n < lc)
|
||||
Del(vector.begin() + n, vector.end());
|
||||
vector.SetCountR(n);
|
||||
Init(vector.begin() + lc, vector.begin() + n);
|
||||
}
|
||||
|
|
@ -577,7 +580,8 @@ template <class T>
|
|||
void Array<T>::SetCountR(int n, const T& init) {
|
||||
ASSERT(n >= 0);
|
||||
int lc = vector.GetCount();
|
||||
Del(vector.begin() + n, vector.end());
|
||||
if(n < lc)
|
||||
Del(vector.begin() + n, vector.end());
|
||||
vector.SetCountR(n);
|
||||
Init(vector.begin() + lc, vector.begin() + n, init);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,11 +114,13 @@ void ImageFilterKernel::Init(double (*kfn)(double), int a, int src_sz, int tgt_s
|
|||
Buffer<int> *k = kache.FindPtr(key);
|
||||
if(k)
|
||||
kernel = *k;
|
||||
Buffer<int>& ktab = kache.GetAdd(key);
|
||||
ktab.Alloc(((2 * a) << shift) + 1);
|
||||
for(int i = 0; i < ((2 * a) << shift) + 1; i++)
|
||||
ktab[i] = int((1 << shift) * (*kfn)((double)i / (1 << shift) - a));
|
||||
kernel = ktab;
|
||||
else {
|
||||
Buffer<int>& ktab = kache.GetAdd(key);
|
||||
ktab.Alloc(((2 * a) << shift) + 1);
|
||||
for(int i = 0; i < ((2 * a) << shift) + 1; i++)
|
||||
ktab[i] = int((1 << shift) * (*kfn)((double)i / (1 << shift) - a));
|
||||
kernel = ktab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ public:
|
|||
void SetClip(const Rectf& rect);
|
||||
Rectf GetClip() const { return cliprect; }
|
||||
|
||||
bool IsValid() const { return min_y < max_y; }
|
||||
int MinY() const { return min_y; }
|
||||
int MaxY() const { return max_y; }
|
||||
bool NotEmpty(int y) { return cell[y].count; }
|
||||
|
|
|
|||
|
|
@ -315,9 +315,9 @@ Buffer<ClippingLine> BufferPainter::RenderPath(double width, One<SpanSource>& ss
|
|||
for(const auto& p : path_info->path) {
|
||||
RenderPathSegments(j.g, p, j.regular ? &pathattr : NULL, j.tolerance);
|
||||
if(width != ONPATH) {
|
||||
int n = rasterizer.MaxY() - rasterizer.MinY();
|
||||
if(n >= 0) {
|
||||
if(rasterizer.IsValid()) {
|
||||
PAINTER_TIMING("RenderPath2 Fill");
|
||||
int n = rasterizer.MaxY() - rasterizer.MinY();
|
||||
if(doco && n > 6) {
|
||||
CoWork co;
|
||||
co * [&] { fill(&co); };
|
||||
|
|
@ -468,8 +468,8 @@ void BufferPainter::FinishPathJob()
|
|||
}
|
||||
};
|
||||
|
||||
int n = maxy - miny;
|
||||
if(n >= 0) {
|
||||
if(miny < maxy) {
|
||||
int n = maxy - miny;
|
||||
if(n > 6) {
|
||||
std::atomic<int> ii(0);
|
||||
CoDo([&] {
|
||||
|
|
|
|||
|
|
@ -760,7 +760,6 @@ RichEdit::RichEdit()
|
|||
pagesz = Size(3968, 6074);
|
||||
unit = UNIT_POINT;
|
||||
zoom = 100;
|
||||
Clear();
|
||||
|
||||
context = NULL;
|
||||
|
||||
|
|
@ -771,6 +770,8 @@ RichEdit::RichEdit()
|
|||
|
||||
overwrite = false;
|
||||
|
||||
Clear();
|
||||
|
||||
sb.WhenScroll = THISBACK(Scroll);
|
||||
sb.SetLine(16);
|
||||
Layout();
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ class PPInfo {
|
|||
VectorMap<String, String> defines[2]; // #define ..., 1 - speculative
|
||||
Index<String> includes[2]; // 1 - speculative includes (in #if conditionals)
|
||||
Index<String> define_includes[2]; // #define LAYOUTFILE
|
||||
bool guarded; // has include guards
|
||||
int blitz; // AUTO, APPROVED, PROHIBITED
|
||||
bool guarded = false; // has include guards
|
||||
int blitz = 0; // AUTO, APPROVED, PROHIBITED
|
||||
Time time = Null; // file time
|
||||
|
||||
bool dirty = true; // need to be rechecked for change (filetime)
|
||||
|
|
|
|||
|
|
@ -412,15 +412,15 @@ IconDes::IconDes()
|
|||
|
||||
bottompane.Bottom(iconshow, 64);
|
||||
|
||||
SetBar();
|
||||
ColorChanged();
|
||||
BackPaint();
|
||||
|
||||
magnify = 13;
|
||||
pen = 1;
|
||||
|
||||
single_mode = false;
|
||||
|
||||
SetBar();
|
||||
ColorChanged();
|
||||
BackPaint();
|
||||
|
||||
status.Width(200);
|
||||
status.NoTransparent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ String CleanupPretty(const String& signature)
|
|||
|
||||
Vector<ItemTextPart> ParsePretty(const String& name, const String& signature, int *fn_info)
|
||||
{
|
||||
bool op = memcmp(name, "operator", 8) == 0 && !iscid(name[8]);
|
||||
bool op = strncmp(name, "operator", 8) == 0 && !iscid(name[8]);
|
||||
Vector<ItemTextPart> part;
|
||||
int name_len = name.GetLength();
|
||||
if(name_len == 0) {
|
||||
|
|
@ -289,7 +289,7 @@ Vector<ItemTextPart> ParsePretty(const String& name, const String& signature, in
|
|||
}
|
||||
else
|
||||
if(iscid(*s) || (*s == '~' && *name == '~')) {
|
||||
if(memcmp(s, name, name_len) == 0 && !iscid(s[name_len]) && !op) { // need strncmp because of e.g. operator++
|
||||
if(strncmp(s, name, name_len) == 0 && !iscid(s[name_len]) && !op) {
|
||||
p.type = ITEM_NAME;
|
||||
n = name_len;
|
||||
const char *q = s + name_len;
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ public:
|
|||
int insert_include;
|
||||
int bordercolumn;
|
||||
bool persistent_find_replace;
|
||||
bool find_replace_restore_pos;
|
||||
bool find_replace_restore_pos = false;
|
||||
int spellcheck_comments;
|
||||
bool wordwrap_comments = true;
|
||||
bool wordwrap = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue