Projects STRLCPY neomutt Commits 9120e744
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    mutt/buffer.c
    skipped 33 lines
    34 34  #include <stdio.h>
    35 35  #include <string.h>
    36 36  #include "buffer.h"
     37 +#include "exit.h"
     38 +#include "logging.h"
    37 39  #include "memory.h"
     40 +#include "message.h"
    38 41  #include "string2.h"
    39 42   
    40 43  static const int BufferStepSize = 128;
    skipped 62 lines
    103 106  {
    104 107   if (!buf || !s)
    105 108   return 0;
     109 + 
     110 + if (len > (SIZE_MAX - BufferStepSize))
     111 + {
     112 + mutt_error(_("Out of memory"));
     113 + mutt_exit(1);
     114 + }
    106 115   
    107 116   if (!buf->data || !buf->dptr || ((buf->dptr + len + 1) > (buf->data + buf->dsize)))
    108 117   mutt_buffer_alloc(buf, buf->dsize + MAX(BufferStepSize, len + 1));
    skipped 162 lines
    271 280   if (buf->data && (new_size <= buf->dsize))
    272 281   return;
    273 282   
     283 + if (new_size > (SIZE_MAX - BufferStepSize))
     284 + {
     285 + mutt_error(_("Out of memory"));
     286 + mutt_exit(1);
     287 + }
     288 + 
    274 289   const bool was_empty = (buf->dptr == NULL);
    275 290   const size_t offset = (buf->dptr && buf->data) ? (buf->dptr - buf->data) : 0;
    276 291   
    277  - if (new_size > SIZE_MAX - BufferStepSize)
    278  - buf->dsize = SIZE_MAX;
    279  - else
    280  - buf->dsize = ROUND_UP(new_size + 1, BufferStepSize);
     292 + buf->dsize = ROUND_UP(new_size + 1, BufferStepSize);
     293 + 
    281 294   mutt_mem_realloc(&buf->data, buf->dsize);
    282 295   mutt_buffer_seek(buf, offset);
    283 296   
    skipped 192 lines
Please wait...
Page is in error, reload to recover